Calculates the number of whole days between two dates, using floor rounding.
Can return negative values if from is after to. Partial days are truncated (e.g., 1.9 days returns 1).
from
to
The start date
The end date (defaults to the current date/time)
Number of whole days between the two dates (may be negative)
daysBetween(new Date('2024-01-01'), new Date('2024-01-10'))// 9 Copy
daysBetween(new Date('2024-01-01'), new Date('2024-01-10'))// 9
daysBetween(new Date('2024-01-10'), new Date('2024-01-01'))// -9 Copy
daysBetween(new Date('2024-01-10'), new Date('2024-01-01'))// -9
Calculates the number of whole days between two dates, using floor rounding.
Can return negative values if
fromis afterto. Partial days are truncated (e.g., 1.9 days returns 1).