Check for leap year

JavaScript, Date · Oct 20, 2020

Checks if the given year is a leap year.

const isLeapYear = year => new Date(year, 1, 29).getMonth() === 1;
isLeapYear(2019); // false
isLeapYear(2020); // true

More like this

  • String is ISO formatted date

    Checks if the given string is valid in the simplified extended ISO format (ISO 8601).

    JavaScript, Date · Nov 29, 2020

  • Format duration

    Returns the human-readable format of the given number of milliseconds.

    JavaScript, Date · Oct 22, 2020

  • Number of seconds to ISO format

    Returns the ISO format of the given number of seconds.

    JavaScript, Date · Oct 13, 2021