Skip to main content

listDaysInMonth

The listDaysInMonth function generates an array of formatted date strings representing each day in a given month and year.

Usage Example

import { listDaysInMonth } from 'calendar-widgets';

const daysInFebruary2023 = listDaysInMonth(2023, 2);
console.log(daysInFebruary2023);
/*
Output:
[
"02/01/2023",
"02/02/2023",
"02/03/2023",
// ...and so on for the remaining days
"02/28/2023"
]
*/

Parameters

The function takes the following parameters:

Name
year
Type
number
Description
Name
month
Type
number
Description

Return Value

The function returns an array of formatted date strings representing each day in the specified month and year.

Errors

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