W3cubDocs

/date-fns

getDaysInYear

Get the number of days in a year of the given date.

Description

Get the number of days in a year of the given date.

Usage

// CommonJS
var getDaysInYear = require('date-fns/getDaysInYear')
// ES 2015
import getDaysInYear from 'date-fns/getDaysInYear'
// ESM
import { getDaysInYear } from 'date-fns'

Syntax

getDaysInYear(date)

Arguments

Name Description
date

the given date

Returns

Description

the number of days in a year

Exceptions

Type Description
TypeError

1 argument required

Examples

// How many days are in 2012?
const result = getDaysInYear(new Date(2012, 0, 1))
//=> 366

© 2021 Sasha Koss and Lesha Koss
Licensed under the MIT License.
https://date-fns.org/v2.29.2/docs/getDaysInYear