Skip to main content

Get the full month from the Date object

· One min read
CTO

Up till now I've been using a date library like dayjs to get the full name of a month. e.g. "April".

Using the standard Date object, getting the month is usually done by

new Date().getMonth()

and for April, it would give me 3; months are indexed from 0.

Now you can use

new Date().toLocaleString('en-GB', { month: 'long' })

which will return April.

To learn more, read these docs.