new Date("Tue Apr 08 2008 00:00:00 GMT+0530").getMonth() returns 3?
Why does this datetime format returns -1 month. Also can any one please tell me is this UTC timestamp or GMT or ISO. I am pretty confused. Any help is greatly appreciated.
new Date("Tue Apr 08 2008 00:00:00 GMT+0530").getMonth() returns 3?
Why does this datetime format returns -1 month. Also can any one please tell me is this UTC timestamp or GMT or ISO. I am pretty confused. Any help is greatly appreciated.
The month field is 0 indexed :
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
month
Integer value representing the month, beginning with 0 for January to 11 for December.
getMonth()
is returning the right date, it's just zero indexed, so Jan = 0, Dec = 11
new Date("Tue Apr 08 2008 00:00:00 GMT+0530").getMonth()
Also, ISO formatted dates look like this:
YYYY-MM-DDTHH:mm:ss.sssZ
If the Z is present, UTC is used, otherwise you can replace the Z with +hh:mm or -hh:mm to specify an offset from UTC.
Possibly because it is returning the month index from base 0.
January=0
Febuary=1
March=2
April =3
etc.
Just a guess though.