Files
wedding-planner/lib/helper/getDaysUntilEvent.ts
briannelson95 e6e24f12d4 pagination
2025-07-02 20:33:23 -04:00

13 lines
425 B
TypeScript

export function getDaysUntilEvent(eventDate: Date): number {
const today = new Date();
const target = new Date(eventDate);
// Clear time from both dates to ensure accurate full-day difference
today.setHours(0, 0, 0, 0);
target.setHours(0, 0, 0, 0);
const diffInMs = target.getTime() - today.getTime();
const diffInDays = Math.ceil(diffInMs / (1000 * 60 * 60 * 24));
return diffInDays;
}