Get the number of minutes between the given dates.
Get the signed number of full (rounded towards 0) minutes between the given dates.
// CommonJS var differenceInMinutes = require('date-fns/differenceInMinutes')
// ES 2015 import differenceInMinutes from 'date-fns/differenceInMinutes'
// ESM import { differenceInMinutes } from 'date-fns'
differenceInMinutes(dateLeft, dateRight, [options])
Name | Description |
---|---|
dateLeft |
the later date |
dateRight |
the earlier date |
options |
an object with options. |
options.roundingMethod |
a rounding method ( |
Description |
---|
the number of minutes |
Type | Description |
---|---|
TypeError |
2 arguments required |
// How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00? const result = differenceInMinutes( new Date(2014, 6, 2, 12, 20, 0), new Date(2014, 6, 2, 12, 7, 59) ) //=> 12
// How many minutes are between 10:01:59 and 10:00:00 const result = differenceInMinutes( new Date(2000, 0, 1, 10, 0, 0), new Date(2000, 0, 1, 10, 1, 59) ) //=> -1
© 2021 Sasha Koss and Lesha Koss
Licensed under the MIT License.
https://date-fns.org/v2.29.2/docs/differenceInMinutes