javascript - setMonth(1) gives me March? -


why setmonth(1) giving me march? believe 0=jan, 1=feb, 2=mar

<!doctype html> <html> <head> <script> window.onload = init;  function init(){ var d = new date(); d.setfullyear(2014); d.setmonth(1); d.setdate(1);  document.getelementbyid("demo").innerhtml = d; } </script> </head> <body>  <div id="demo"></div>  </body> </html> 

i get...

sat mar 01 2014 15:11:03 gmt-0600 (central standard time)

i'm running win7 pro 64-bit , clock , calendar seem correct.

today 31st of january. when d.setmonth(1); trying set date 31st of february. since date doesn't exist, falls on 3rd of march.

set whole date when initialise object, don't try change piecemeal.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -