Strange behavior of javascript date object. Unable to create correct date -


when run code bellow:

var d = new date(1958, 12, 23); console.log(d.getfullyear());  console.log(d.getmonth()); console.log(d.getdate()); 

it returns wrong year , month. jumps 1959.

why?

because months 0 indexed.

try running:

var d = new date(1958, 11, 23); console.log(d.todatestring()); // tue dec 23 1958 

Comments

Popular posts from this blog

php - Extract Text from HTTP referer -

Receive udp packets in android gstreamer -

authentication - ASP.NET Core 1.0. Bearer Token, cannot access custom claims -