Is the given date in the same year as the current date?
Is the given date in the same year as the current date?
⚠️ Please note that this function is not present in the FP submodule as it uses
Date.now()internally hence impure and can't be safely curried.
// CommonJS
var isThisYear = require('date-fns/isThisYear')
// ES 2015 import isThisYear from 'date-fns/isThisYear'
// ESM
import { isThisYear } from 'date-fns'
isThisYear(date)
| Name | Description |
|---|---|
date |
the date to check |
| Description |
|---|
|
the date is in this year |
| Type | Description |
|---|---|
TypeError |
1 argument required |
// If today is 25 September 2014, is 2 July 2014 in this year? const result = isThisYear(new Date(2014, 6, 2)) //=> true
© 2021 Sasha Koss and Lesha Koss
Licensed under the MIT License.
https://date-fns.org/v2.29.2/docs/isThisYear