Connecting Tech Pros Worldwide Help | Site Map

javascript default date is one month off

  #1  
Old December 6th, 2005, 07:25 AM
ahmedbm@gmail.com
Guest
 
Posts: n/a
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

  #2  
Old December 6th, 2005, 07:35 AM
Lasse Reichstein Nielsen
Guest
 
Posts: n/a

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.'
  #3  
Old December 6th, 2005, 07:45 AM
ahmedbm@gmail.com
Guest
 
Posts: n/a

re: javascript default date is one month off


lol, i guess that answers my question! :)

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript runtime error KRISHNA PRAVI answers 1 January 29th, 2008 10:01 AM
Problem in Event Handling sorobor answers 2 July 11th, 2007 01:01 PM
JavaScript to Enter Date & Null Bob Sanderson answers 3 April 17th, 2007 08:45 PM
dd/mm/yyyy Date Compare Problem Assimalyst answers 12 April 30th, 2006 11:55 PM