getMonth
The `getMonth` function retrieves the numeric representation of the month (e.g., `01`, `11`) from a given date. If no date is provided, it defaults to the current date.> getMonth(date?: Date | FixedDate | null): string
- date: Optional date to extract the month from, defaults to the current date. Accepts a Date object, a string in `YYYY-MM-DD` format, or null.
- Returns: The month as a string in `MM` format.
Example
import { getMonth } from "@explita/daily-toolset";
// Default: current date
getMonth(); // "11" (if today's month is November)
// Specified date
getMonth(new Date("2024-11-04")); // "11"
// Using a fixed date string
getMonth("2024-11-04"); // "11"