Skip to main content

getDaysInMonth

The getDaysInMonth function calculates the number of days in a given month and year.

Usage Example

import { getDaysInMonth } from 'calendar-widgets';

const daysInFebruary = getDaysInMonth(2023, 2);
console.log(daysInFebruary); // Output: 28

Parameters

Name
year
Type
number
Description
An integer representing the year for which to calculate the number of days, between 1900 and 2100.
Name
month
Type
number
Description
An integer representing the month for which to calculate the number of days, between 1 and 12.

Return Value

The function returns an integer representing the number of days in the specified month and year.

Errors

The function throws an error if the year parameter is not a valid year between 1900 and 2100, or if the month parameter is not a valid month between 1 and 12.