Get the first day of the month for a date.
Code
Generalconst date = new Date(dateStr);
return new Date(date.getFullYear(), date.getMonth(), 1).toISOString().split('T')[0];Parameters
Date string
Browser·fetch() may be limited by CORS
More JavaScript Snippets
Add Days to Date
Add a specified number of days to a date and return the result in ISO format.
Business Days Between
Calculate the number of business days (weekdays) between two dates. Excludes Saturdays and Sundays, useful for project planning and SLA calculations.
Calculate Age
Calculate age in years from a birth date, accounting for month and day.
Count Working Days
Count working days (excluding weekends) between dates.
Days Between Dates
Calculate the number of days between two dates.
Days in Month
Get the number of days in a specific month.