Announcement

Collapse
No announcement yet.

Date() problem?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Date() problem?

    The dates obtained from Date() are printing one month later than supposed to be.
    Jan is printing as Feb, Feb as March etc.

    v1 = new Date(2002, 12, 12);
    v2 = new Date(2003, 1, 11);
    v3 = new Date(2003, 2, 12);
    v4 = new Date(2003, 3, 13);
    debugPrintln(v1+" "+v2+" "+v3+" "+v4);

    prints:
    Jan 12, 2003 Feb 11, 2003 Mar 12, 2003 Apr 13, 2003

    syntax should be
    var newDateObject = new Date(year, month, day);

    my local time is set to -8 Pacific Time

    do you see the same behavior?
    thanks
    phil

  • #2
    month starts at 0 for jan and runs thru 11 for dec, so 12 is also january the next year

    Comment


    • #3
      Thank you

      Comment


      • #4
        Re: Reply to post 'Date() problem?'

        With the date object, 0 is January, 11 is December. If you go above 11 for the
        month, it rolls over.

        --- [email protected] wrote:
        > Hello mattgundersen,
        >
        > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        >
        Matt Gundersen

        Comment

        Working...
        X