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

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -