...

View Full Version : got stucked with date() object



deshi2003
05-28-2009, 11:01 AM
hey i was working on Date() object of javascript

when i write

today=new Date();
year=today.getYear();
month=today.getMonth();
day=today.getDay();

here everything was correct but when i print month then i got currentmonth-1 that if the currentmonth is 5 then t get 4

if the current month is 07 then i get 06.


at last i worked by adding 1 with month like month+1

is there any one who faced this problem or know about this problem.

please let me know what is the cause behind this

venegal
05-28-2009, 11:22 AM
That's no problem, that's just how it works. getMonth returns 0-11 and not 1-12, just like getDay returns 0-6, and not 1-7.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum