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

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -