Skip to main content
5-Regular Member
June 12, 2018
Question

this function returns previous month and not the current month

  • June 12, 2018
  • 1 reply
  • 2561 views

var currentdate = new Date();

currentdate.getMonth();

 

For example, this return 5 instead of 6.

1 reply

16-Pearl
June 12, 2018

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

asekar5-Regular MemberAuthor
5-Regular Member
June 12, 2018
Thanks for the response. I got the point.

Now what is the best way to get the current month ?
16-Pearl
June 12, 2018

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

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