JavaScript getMonth and getDay not returning correct values

Discussion in 'Javascript' started by maflatoun, Apr 7, 2006.

  1. maflatoun

    maflatoun Guest

    Hi,

    I must be losing my mind why is the following code returning wrong
    values?

    var d = new Date();
    alert(d); -> Fri Apr 7 09:28:18 EDT 2006
    alert("Hour:" + d.getHours()); -> 9
    alert("Year:" + d.getYear()); -> 2006
    alert("Month:" + d.getMonth()); -> 3
    alert("Day:" + d.getDay()); -> 5

    Thanks
    Maz.
     
    maflatoun, Apr 7, 2006
    #1
    1. Advertisements

  2. maflatoun

    Evertjan. Guest

    wrote on 07 apr 2006 in comp.lang.javascript:
    Indeed.

    It is correct, please read the specs!
    3 = April [0 = January]

    5 = Friday [0 = Sunday]

    Lookup: getDate()
     
    Evertjan., Apr 7, 2006
    #2
    1. Advertisements

  3. maflatoun

    maflatoun Guest

    thanks... I got it... It's early friday morning and I wasn't thinking
    :)
     
    maflatoun, Apr 7, 2006
    #3
  4. maflatoun

    Evertjan. Guest

    wrote on 07 apr 2006 in comp.lang.javascript:
    Where are you talking about?

    This is usenet not email.

    Please quote what you are replying to. If you want to post a followup via
    groups.google.com, don't use the "Reply" link at the bottom of the article.
    Click on "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers.
    <http://www.safalra.com/special/googlegroupsreply/>
     
    Evertjan., Apr 7, 2006
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.