Skip to main content

Function: minutesBetween()

minutesBetween(a, b): number

Defined in: src/lib/dates/tz.ts:144

Whole minutes between two instants (b − a).

Timezone-free: operates on absolute Date instants, so DST transitions between a and b are already accounted for (the result is elapsed real-world minutes, not wall-clock difference). Rounded to the nearest minute via Math.round, which breaks ties toward +Infinity (not away from zero): a +30s gap rounds to 1, a −30s gap rounds to 0. Returns negative when b precedes a.

Parameters

a

Date

The start instant.

b

Date

The end instant.

Returns

number

Elapsed whole minutes from a to b, rounded to the nearest minute; negative if b < a. If a or b is an invalid Date, the result is NaN (this function does not throw).