Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    74
    Thanks
    2
    Thanked 0 Times in 0 Posts

    got stucked with date() object

    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
    Last edited by deshi2003; 05-28-2009 at 12:05 PM.

  • #2
    Gütkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •