Weird date stuff...

Discussion in 'Javascript' started by John Kiernan, Aug 15, 2004.

  1. John Kiernan

    John Kiernan Guest

    Hey JavaScript gurus!

    Here's a weird one:

    If I check (with an alert) this line:
    vStrDate2 = vDate.toLocaleString();

    I get: Saturday, August 14, 2004 7:57:30 PM (as I should)

    but this operation...

    vStrDate = vDate.getMonth() + "/" + vDate.getDate() + "/" + vDate.getYear();

    Avails me: 7/14/2004 (!?!?!?!)

    I check my computer date and it definitely believes (as do I) that it is
    August. Any idea why getmonth() thinks it's July?

    Also, is there an easier way to get this American date string?

    TIA!

    -- John Kiernan, KierPro Associates
    Custom VFP/Accounting Programming
    and Web interfaces
    VFP and/or SQL back ends
    John Kiernan, Aug 15, 2004
    #1
    1. Advertising

  2. John Kiernan

    John Kiernan Guest

    Okay, I figured out I should just do:

    vStrDate = vDate()

    (I'm new, bear with me), but....

    It still thinks it's July!?!?! Anybody know why?

    TIA, redux...

    -- John Kiernan, KierPro Associates
    Custom VFP/Accounting Programming
    and Web interfaces
    VFP and/or SQL back ends


    "John Kiernan" <> wrote in message
    news:KkATc.6886$...
    > Hey JavaScript gurus!
    >
    > Here's a weird one:
    >
    > If I check (with an alert) this line:
    > vStrDate2 = vDate.toLocaleString();
    >
    > I get: Saturday, August 14, 2004 7:57:30 PM (as I should)
    >
    > but this operation...
    >
    > vStrDate = vDate.getMonth() + "/" + vDate.getDate() + "/" +

    vDate.getYear();
    >
    > Avails me: 7/14/2004 (!?!?!?!)
    >
    > I check my computer date and it definitely believes (as do I) that it is
    > August. Any idea why getmonth() thinks it's July?
    >
    > Also, is there an easier way to get this American date string?
    >
    > TIA!
    >
    > -- John Kiernan, KierPro Associates
    > Custom VFP/Accounting Programming
    > and Web interfaces
    > VFP and/or SQL back ends
    >
    >
    >
    John Kiernan, Aug 15, 2004
    #2
    1. Advertising

  3. John Kiernan

    Lee Guest

    John Kiernan said:
    >
    >Hey JavaScript gurus!
    >
    >Here's a weird one:
    >
    >If I check (with an alert) this line:
    >vStrDate2 = vDate.toLocaleString();
    >
    >I get: Saturday, August 14, 2004 7:57:30 PM (as I should)
    >
    >but this operation...
    >
    >vStrDate = vDate.getMonth() + "/" + vDate.getDate() + "/" + vDate.getYear();
    >
    >Avails me: 7/14/2004 (!?!?!?!)
    >
    >I check my computer date and it definitely believes (as do I) that it is
    >August. Any idea why getmonth() thinks it's July?


    It doesn't think it's July. Month 7 is August. Month 0 is January.
    That makes it much easier to use as an index into an array of month names.

    See the FAQ and the references it contains for date manipulation.
    http://www.jibbering.com/faq/
    Lee, Aug 15, 2004
    #3
  4. John Kiernan

    John Kiernan Guest

    >>See the FAQ and the references it contains for date manipulation.
    >>http://www.jibbering.com/faq/


    I'd love to (and tried) but it's been down all day. Thanks for the answer
    on the question though...

    -- John Kiernan, KierPro Associates
    Custom VFP/Accounting Programming
    and Web interfaces
    VFP and/or SQL back ends


    "Lee" <> wrote in message
    news:...
    > John Kiernan said:
    > >
    > >Hey JavaScript gurus!
    > >
    > >Here's a weird one:
    > >
    > >If I check (with an alert) this line:
    > >vStrDate2 = vDate.toLocaleString();
    > >
    > >I get: Saturday, August 14, 2004 7:57:30 PM (as I should)
    > >
    > >but this operation...
    > >
    > >vStrDate = vDate.getMonth() + "/" + vDate.getDate() + "/" +

    vDate.getYear();
    > >
    > >Avails me: 7/14/2004 (!?!?!?!)
    > >
    > >I check my computer date and it definitely believes (as do I) that it is
    > >August. Any idea why getmonth() thinks it's July?

    >
    > It doesn't think it's July. Month 7 is August. Month 0 is January.
    > That makes it much easier to use as an index into an array of month names.
    >
    > See the FAQ and the references it contains for date manipulation.
    > http://www.jibbering.com/faq/
    >
    John Kiernan, Aug 15, 2004
    #4
  5. On Sun, 15 Aug 2004 04:46:05 GMT, John Kiernan <>
    wrote:

    >>> See the FAQ and the references it contains for date manipulation.
    >>> http://www.jibbering.com/faq/

    >
    > I'd love to (and tried) but it's been down all day. [...]


    Yes, it has. However, the FAQ is posted three times a week. From the FAQ:

    "The FAQ will currently be posted in two parts, one part (the
    Quick Answers) on Mondays and Fridays, with the remainder posted
    on wednesdays."

    The post on Friday was made just before 1200 GMT.

    [snip]

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail
    Michael Winter, Aug 15, 2004
    #5
  6. JRS: In article <hUBTc.7485$>, dated Sun,
    15 Aug 2004 04:46:05, seen in news:comp.lang.javascript, John Kiernan
    <> posted :
    >>>See the FAQ and the references it contains for date manipulation.
    >>>http://www.jibbering.com/faq/

    >
    >I'd love to (and tried) but it's been down all day. Thanks for the answer
    >on the question though...
    >
    >-- John Kiernan, KierPro Associates
    >Custom VFP/Accounting Programming
    >and Web interfaces
    >VFP and/or SQL back ends


    Responses should go after trimmed quotes. The correct signature
    delimiter is a line containing only minus minus space . Agreed about
    jibbering down-ness; perhaps there should be a mirror at a reliable ISP?
    Garbo might be willing to take it, and Garbo is itself mirrored ...


    >> >Avails me: 7/14/2004 (!?!?!?!)


    For Web use, the Web being international, you should use 2004-08-14
    19:57:30, and add a time zone indication. AIUI, YYYY-MM-DD is in FIPS.


    >> It doesn't think it's July. Month 7 is August. Month 0 is January.
    >> That makes it much easier to use as an index into an array of month names.


    You exaggerate. Adding 1, or using MNA = ['', 'Jan', 'Feb', ... is not
    really difficult.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
    Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
    PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
    Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
    Dr John Stockton, Aug 15, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    588
    Matthew Speed
    Nov 8, 2003
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,229
    Michael Borgwardt
    May 30, 2004
  3. Matt
    Replies:
    2
    Views:
    505
    Pete Becker
    Nov 8, 2003
  4. Replies:
    7
    Views:
    324
    Keith Thompson
    Feb 23, 2007
  5. aurora

    Weird stuff in VHDL

    aurora, Apr 9, 2007, in forum: VHDL
    Replies:
    1
    Views:
    435
    martin.wahlstedt
    Apr 10, 2007
Loading...

Share This Page