Calculates the number of whole days between two dates, clamped to zero.
Returns 0 if from is after to — reversed ranges and clock-skew do not produce negative values. Partial days are truncated (e.g., 1.9 days -> 1).
0
from
to
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
Calculates the number of whole days between two dates, clamped to zero.
Returns
0iffromis afterto— reversed ranges and clock-skew do not produce negative values. Partial days are truncated (e.g., 1.9 days -> 1).