Get the year of the given date.
Get the year of the given date.
// CommonJS
var getYear = require('date-fns/getYear')
// ES 2015 import getYear from 'date-fns/getYear'
// ESM
import { getYear } from 'date-fns'
getYear(date)
| Name | Description |
|---|---|
date |
the given date |
| Description |
|---|
|
the year |
| Type | Description |
|---|---|
TypeError |
1 argument required |
// Which year is 2 July 2014? const result = getYear(new Date(2014, 6, 2)) //=> 2014
© 2021 Sasha Koss and Lesha Koss
Licensed under the MIT License.
https://date-fns.org/v2.29.2/docs/getYear