Get the number of full years between the given dates.
Get the number of full years between the given dates.
// CommonJS var differenceInYears = require('date-fns/differenceInYears')
// ES 2015 import differenceInYears from 'date-fns/differenceInYears'
// ESM import { differenceInYears } from 'date-fns'
differenceInYears(dateLeft, dateRight)
Name | Description |
---|---|
dateLeft |
the later date |
dateRight |
the earlier date |
Description |
---|
the number of full years |
Type | Description |
---|---|
TypeError |
2 arguments required |
// How many full years are between 31 December 2013 and 11 February 2015? const result = differenceInYears(new Date(2015, 1, 11), new Date(2013, 11, 31)) //=> 1
© 2021 Sasha Koss and Lesha Koss
Licensed under the MIT License.
https://date-fns.org/v2.29.2/docs/differenceInYears