Weird date stuff...

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

    #1

    Weird date stuff...

    Hey JavaScript gurus!

    Here's a weird one:

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

    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

    #2
    Re: Weird date stuff...

    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" <kiernan.je@ver izon.net> wrote in message
    news:KkATc.6886 $SC1.6572@nwrdd c03.gnilink.net ...[color=blue]
    > Hey JavaScript gurus!
    >
    > Here's a weird one:
    >
    > If I check (with an alert) this line:
    > vStrDate2 = vDate.toLocaleS tring();
    >
    > I get: Saturday, August 14, 2004 7:57:30 PM (as I should)
    >
    > but this operation...
    >
    > vStrDate = vDate.getMonth( ) + "/" + vDate.getDate() + "/" +[/color]
    vDate.getYear() ;[color=blue]
    >
    > 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
    >
    >
    >[/color]


    Comment

    • Lee

      #3
      Re: Weird date stuff...

      John Kiernan said:[color=blue]
      >
      >Hey JavaScript gurus!
      >
      >Here's a weird one:
      >
      >If I check (with an alert) this line:
      >vStrDate2 = vDate.toLocaleS tring();
      >
      >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?[/color]

      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.


      Comment

      • John Kiernan

        #4
        Re: Weird date stuff...

        >>See the FAQ and the references it contains for date manipulation.[color=blue][color=green]
        >>http://www.jibbering.com/faq/[/color][/color]

        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" <REM0VElbspamtr ap@cox.net> wrote in message
        news:cfmkv9022k d@drn.newsguy.c om...[color=blue]
        > John Kiernan said:[color=green]
        > >
        > >Hey JavaScript gurus!
        > >
        > >Here's a weird one:
        > >
        > >If I check (with an alert) this line:
        > >vStrDate2 = vDate.toLocaleS tring();
        > >
        > >I get: Saturday, August 14, 2004 7:57:30 PM (as I should)
        > >
        > >but this operation...
        > >
        > >vStrDate = vDate.getMonth( ) + "/" + vDate.getDate() + "/" +[/color][/color]
        vDate.getYear() ;[color=blue][color=green]
        > >
        > >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?[/color]
        >
        > 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/
        >[/color]


        Comment

        • Michael Winter

          #5
          Re: Weird date stuff...

          On Sun, 15 Aug 2004 04:46:05 GMT, John Kiernan <kiernan.je@ver izon.net>
          wrote:
          [color=blue][color=green][color=darkred]
          >>> See the FAQ and the references it contains for date manipulation.
          >>> http://www.jibbering.com/faq/[/color][/color]
          >
          > I'd love to (and tried) but it's been down all day. [...][/color]

          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

          Comment

          • Dr John Stockton

            #6
            Re: Weird date stuff...

            JRS: In article <hUBTc.7485$SC1 .3455@nwrddc03. gnilink.net>, dated Sun,
            15 Aug 2004 04:46:05, seen in news:comp.lang. javascript, John Kiernan
            <kiernan.je@ver izon.net> posted :[color=blue][color=green][color=darkred]
            >>>See the FAQ and the references it contains for date manipulation.
            >>>http://www.jibbering.com/faq/[/color][/color]
            >
            >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[/color]

            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 ...

            [color=blue][color=green][color=darkred]
            >> >Avails me: 7/14/2004 (!?!?!?!)[/color][/color][/color]

            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.

            [color=blue][color=green]
            >> 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.[/color][/color]

            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.demo n.co.uk/> - w. FAQish topics, links, acronyms
            PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
            Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.

            Comment

            Working...