Skip to main content
5-Regular Member
Question

this function returns previous month and not the current month

var currentdate = new Date();

currentdate.getMonth();

 

For example, this return 5 instead of 6.

5 replies

16-Pearl

Hi Asekar,

 

getMonth() method returns the month (from 0 to 11) for the specified date, according to local time.

https://www.w3schools.com/jsref/jsref_getmonth.asp

Translate
asekar5-Regular MemberAuthor
5-Regular Member
Thanks for the response. I got the point.

Now what is the best way to get the current month ?
Translate
16-Pearl

The month number would be : currentdate.getMonth()+1

Are you looking for the month Name (January, ...) ? Do you want it localized ?

Translate