Connecting Tech Pros Worldwide Help | Site Map

javascript default date is one month off

ahmedbm@gmail.com
Guest
 
Posts: n/a
#1: Dec 6 '05
I just noticed that all my javascript months are off by one
month.....didn't test multiple systems tho and my system date is fine.

Any way of fixing this?

TIA,
Ahmed

Lasse Reichstein Nielsen
Guest
 
Posts: n/a
#2: Dec 6 '05

re: javascript default date is one month off


ahmedbm@gmail.com writes:
[color=blue]
> I just noticed that all my javascript months are off by one
> month.....didn't test multiple systems tho and my system date is fine.
>
> Any way of fixing this?[/color]

Most likely by realising that the results returned by Date's getMonth
is zero-based, i.e., 0 for January and 11 for December. Knowing that
instantly makes the results correct :)

/L
--
Lasse Reichstein Nielsen - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
ahmedbm@gmail.com
Guest
 
Posts: n/a
#3: Dec 6 '05

re: javascript default date is one month off


lol, i guess that answers my question! :)

Closed Thread


Similar JavaScript / Ajax / DHTML bytes