Date() - year missing since clocks changed

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

    Date() - year missing since clocks changed

    I have a page that uses the javascript Date() function to retrieve a date
    from the client computer.
    The date is then inserted into a note that is saved on a database. The date
    is in the format
    Thursay Oct 30 2003 10.47am

    When I access the page using my computer everything works fine.
    A colleague in the UK also uses the page and it was fine up until the clocks
    changed last weekend. Now notes that he saves have the date in the format
    Thursday Oct 30 10.47am i.e. the year is missing.

    Presumably something has happened to the date information on his computer so
    that Date() is not getting the year any longer. Can anyone suggest how I
    might sort this out?

    Thanks
    Orson


  • Lasse Reichstein Nielsen

    #2
    Re: Date() - year missing since clocks changed

    "Orson" <bilge43@yahoo. com> writes:
    [color=blue]
    > Presumably something has happened to the date information on his computer so
    > that Date() is not getting the year any longer.[/color]

    Highly unlikely. The Date object is ususally highly resilient about changes.
    User code is not.
    [color=blue]
    > Can anyone suggest how I might sort this out?[/color]

    Not without showing us the code that fails.

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • Orson

      #3
      Re: Date() - year missing since clocks changed


      "Lasse Reichstein Nielsen" <lrn@hotpop.com > wrote in message
      news:ekwtbosc.f sf@hotpop.com.. .[color=blue]
      > "Orson" <bilge43@yahoo. com> writes:
      >[color=green]
      > > Presumably something has happened to the date information on his[/color][/color]
      computer so[color=blue][color=green]
      > > that Date() is not getting the year any longer.[/color]
      >
      > Highly unlikely. The Date object is ususally highly resilient about[/color]
      changes.[color=blue]
      > User code is not.[/color]

      You are correct. Thanks for getting me to think straight. Next week when I
      can check it, I am sure I will find the answer lies in the manner I am
      chopping up the Date string which will have changed with the switch from
      Summer Time.


      Comment

      • Dr John Stockton

        #4
        Re: Date() - year missing since clocks changed

        JRS: In article <bntbde$3j7$1@l ust.ihug.co.nz> , seen in
        news:comp.lang. javascript, Orson <bilge43@yahoo. com> posted at Fri, 31
        Oct 2003 22:59:25 :-[color=blue]
        >
        >Presumably something has happened to the date information on his computer so
        >that Date() is not getting the year any longer. Can anyone suggest how I
        >might sort this out?
        >[/color]

        Probably you mean new Date() above. The value is a date variable
        is stored as milliseconds from 1970-01-01 00:00:00 GMT, and there is no
        prospect of the year going absent.

        It is conceivable that the year corresponding to the date currently
        stored is cached within the object, for efficiency; but even in that
        case I would not expect blank or spaces to be returned.

        Where the browser is suspected, a questioner should report details of
        the system. But it is probable that the code is wrong; it cannot be
        diagnosed in more detail without seeing it. Or the database is in
        error; arrange to display exactly what is being sent to it.


        As you are in NZ, could you check Web <URL:http://www.merlyn.demon.co.uk
        /js-date5.htm#Demo> , yellow form, for correctness with NZ selected where
        UK initially appears? Select NZ, then Run.

        --
        © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
        <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
        <URL:http://www.merlyn.demo n.co.uk/js-index.htm> JS maths, dates, sources.
        <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.

        Comment

        • Lee

          #5
          Re: Date() - year missing since clocks changed

          Orson said:[color=blue]
          >
          >
          >"Lasse Reichstein Nielsen" <lrn@hotpop.com > wrote in message
          >news:ekwtbosc. fsf@hotpop.com. ..[color=green]
          >> "Orson" <bilge43@yahoo. com> writes:
          >>[color=darkred]
          >> > Presumably something has happened to the date information on his[/color][/color]
          >computer so[color=green][color=darkred]
          >> > that Date() is not getting the year any longer.[/color]
          >>
          >> Highly unlikely. The Date object is ususally highly resilient about[/color]
          >changes.[color=green]
          >> User code is not.[/color]
          >
          >You are correct. Thanks for getting me to think straight. Next week when I
          >can check it, I am sure I will find the answer lies in the manner I am
          >chopping up the Date string which will have changed with the switch from
          >Summer Time.[/color]

          That's a good reason not to get information by chopping up
          the Date string. The Date object has methods that return
          the month, date, year, day of week, etc.

          Comment

          • Dr John Stockton

            #6
            Re: Date() - year missing since clocks changed

            JRS: In article <bnul15$q8a$1@l ust.ihug.co.nz> , seen in
            news:comp.lang. javascript, Orson <bilge43@yahoo. com> posted at Sat, 1
            Nov 2003 10:49:38 :-[color=blue]
            >
            >"Lasse Reichstein Nielsen" <lrn@hotpop.com > wrote in message
            >news:ekwtbosc. fsf@hotpop.com. ..[color=green]
            >> "Orson" <bilge43@yahoo. com> writes:
            >>[color=darkred]
            >> > Presumably something has happened to the date information on his[/color][/color]
            >computer so[color=green][color=darkred]
            >> > that Date() is not getting the year any longer.[/color]
            >>
            >> Highly unlikely. The Date object is ususally highly resilient about[/color]
            >changes.[color=green]
            >> User code is not.[/color]
            >
            >You are correct. Thanks for getting me to think straight. Next week when I
            >can check it, I am sure I will find the answer lies in the manner I am
            >chopping up the Date string which will have changed with the switch from
            >Summer Time.[/color]

            For me,
            new Date(2003, 05) Sun Jun 1 00:00:00 UTC+0100 2003
            new Date(2003, 11) Mon Dec 1 00:00:00 UTC 2003


            **NEVER** lightly disassemble a string whose format is not rigorously
            defined either by yourself or in a document which you have reason to
            believe is heeded. Consider whether your browser supplier is likely to
            heed documents.

            Not only may there be an overlooked variation such as above, but there
            may be a variation with browser (etc.) version, or with localisation.

            Use the string output functions at most for showing to a human who can
            be expected to recognise what it means.

            Avoid the string input functions, except that D = new Date("2003/11/01")
            seems safe, with 4-digit year, YMD order, and / separator (anyone find
            otherwise?), and strings with 4-digit years and month names seem safe if
            the spelling can be trusted worldwide.




            I've noticed that (in my MSIE4) J = Date.UTC(Year) accepts years
            outside the Date Object range - it gives a big number for year 1E297,
            and Infinity for 1E298. For large N, Date.UTC(N)/N is, as expected,
            close to 31556952000.

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

            • Orson

              #7
              Re: Date() - year missing since clocks changed


              "Dr John Stockton" <spam@merlyn.de mon.co.uk> wrote in message
              news:wmIQVgArIv o$EwwK@merlyn.d emon.co.uk...[color=blue]
              > JRS: In article <bntbde$3j7$1@l ust.ihug.co.nz> , seen in
              > news:comp.lang. javascript, Orson <bilge43@yahoo. com> posted at Fri, 31
              > Oct 2003 22:59:25 :-[color=green]
              > >
              > >Presumably something has happened to the date information on his computer[/color][/color]
              so[color=blue][color=green]
              > >that Date() is not getting the year any longer. Can anyone suggest how I
              > >might sort this out?
              > >[/color]
              >
              > Probably you mean new Date() above. The value is a date variable
              > is stored as milliseconds from 1970-01-01 00:00:00 GMT, and there is no
              > prospect of the year going absent.
              >
              > It is conceivable that the year corresponding to the date currently
              > stored is cached within the object, for efficiency; but even in that
              > case I would not expect blank or spaces to be returned.
              >
              > Where the browser is suspected, a questioner should report details of
              > the system. But it is probable that the code is wrong; it cannot bet
              > diagnosed in more detail without seeing it. Or the database is in
              > error; arrange to display exactly what is being sent to it.
              >
              >
              > As you are in NZ, could you check Web <URL:http://www.merlyn.demon.co.uk
              > /js-date5.htm#Demo> , yellow form, for correctness with NZ selected where
              > UK initially appears? Select NZ, then Run.[/color]

              It was in the code.
              I am embarrassed to say that I had chopped up the string without regard for
              the consequences. I am now using the proper date object methods and the
              problem is resolved.

              With regard to your demo page, everything appears in order when I set the
              form to NZ and click run.

              Thank you all for your help.

              Orson


              Comment

              Working...