startOfMonth

Modified on Tue, 22 Aug 2023

Description

Use this function to obtain the start date of a month for a given date. The result will be in the local timezone, and it represents the first day of the month in which the input date falls.

Syntax

startOfMonth(date)

Returns

Return ValueDescription
DateReturns a Date object representing the start of the month for the given date in the local timezone.

Sample

ExampleResultDescription
startOfMonth(2023-06-15)2023-06-01The function returns the start of the month for June 15, 2023, which is June 1, 2023, in the local timezone.
startOfMonth(1990-12-31)1990-12-01The function returns the start of the month for December 31, 1990, which is December 1, 1990, in the local timezone.
startOfMonth(1975-09-05)1975-09-01The function returns the start of the month for September 5, 1975, which is September 1, 1975, in the local timezone.

To view all the Date functions, click here.

See Also