Date/Time Question

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

    Date/Time Question

    Many scripts and calendars call client side system time in order to
    make presentations.

    However, the client's time may be improperly set, if set at all,
    and/or the relevant time may be from another time zone.

    It would be of great value if the time of some central source could be
    drawn, in the form of a ".js" file, into the script to avoid
    dependence on the client's date/time.

    Even if such a central source produced a new file, extention ".js"
    with such simple text as Date(,,) with the proper attributes of year,
    month, day, hour and minute, a new file produced every 5 minutes (for
    example), there would be a great many applications.

    Does anyone know of such a source?

    Is anyone interested in donating/hosting such a utility?
    Even just a once every half hour genetor would have merit.

    Please reply to may_NOSPAM_@eas tontario.com (remove the _NOSPAM_ part)
  • McKirahan

    #2
    Re: Date/Time Question

    "Gord" <nov@eastontari o.com> wrote in message
    news:31224617.0 312180806.54bf5 a33@posting.goo gle.com...[color=blue]
    > Many scripts and calendars call client side system time in order to
    > make presentations.
    >
    > However, the client's time may be improperly set, if set at all,
    > and/or the relevant time may be from another time zone.
    >
    > It would be of great value if the time of some central source could be
    > drawn, in the form of a ".js" file, into the script to avoid
    > dependence on the client's date/time.
    >
    > Even if such a central source produced a new file, extention ".js"
    > with such simple text as Date(,,) with the proper attributes of year,
    > month, day, hour and minute, a new file produced every 5 minutes (for
    > example), there would be a great many applications.
    >
    > Does anyone know of such a source?
    >
    > Is anyone interested in donating/hosting such a utility?
    > Even just a once every half hour genetor would have merit.
    >
    > Please reply to may_NOSPAM_@eas tontario.com (remove the _NOSPAM_ part)[/color]


    The following uses ASP to return the current server-side timestamp; (watch
    for word-wrap):

    <% @Language="VBSc ript" %>
    <% Option Explicit
    Function TimeStamp()
    '*
    '* Timestamp() returns "ccyymmddhhnnss "
    '*
    Dim arrNOW(6)
    arrNOW(0) = Now()
    arrNOW(1) = DatePart("yyyy" ,arrNOW(0))
    arrNOW(2) = DatePart("m",ar rNOW(0))
    arrNOW(3) = DatePart("d",ar rNOW(0))
    arrNOW(4) = DatePart("h",ar rNOW(0))
    arrNOW(5) = DatePart("n",ar rNOW(0))
    arrNOW(6) = DatePart("s",ar rNOW(0))
    Dim intNOW
    Dim strNOW
    strNOW = ""
    '*
    For intNOW = 1 To UBound(arrNOW)
    If (arrNOW(intNOW) < 10) Then
    arrNOW(intNOW) = "0" & arrNOW(intNOW)
    End If
    strNOW = strNOW & arrNOW(intNOW)
    Next
    '*
    TimeStamp = strNOW
    End Function
    %>
    <html>
    <head>
    <title>TimeStam p.asp</title>
    </head>
    <body>
    <%=TimeStamp()% >
    </body>
    </html>


    Comment

    • Dr John Stockton

      #3
      Re: Date/Time Question

      JRS: In article <31224617.03121 80806.54bf5a33@ posting.google. com>, seen
      in news:comp.lang. javascript, Gord <nov@eastontari o.com> posted at Thu,
      18 Dec 2003 08:06:36 :-
      [color=blue]
      >Many scripts and calendars call client side system time in order to
      >make presentations.
      >
      >However, the client's time may be improperly set, if set at all,
      >and/or the relevant time may be from another time zone.
      >
      >It would be of great value if the time of some central source could be
      >drawn, in the form of a ".js" file, into the script to avoid
      >dependence on the client's date/time.[/color]


      The returned date/time needs to be GMT. For us, the best form would be
      as a value of milliseconds since 1970-01-01 00:00:00 GMT, which can be
      directly applied : var T = new Date(Number) or new Date(+String) .

      There is no need for a _central_ source; reliable time, sufficiently
      accurately, is available to servers worldwide.

      Converting time between zones is AFAICS a solved problem, provided that
      a valid TZ string can be supplied for each remote location, and that the
      zone of a remote time us unambiguously indicated. See far below.

      QHAH.


      In article <5wkEb.80063$8y 1.286217@attbi_ s52>, seen in
      news:comp.lang. javascript, McKirahan <News@McKirahan .com> posted at Thu,
      18 Dec 2003 16:23:29 :-[color=blue]
      >
      ><% @Language="VBSc ript" %>[/color]

      Which can be reduced using

      s = Now
      y = year(s) : ... : s = seconds(s)
      TimeStamp = ((((Y*100+M)*10 0+D)*100+h)*100 +n)*100+s

      assuming this VBscript is like what I have.


      --
      © 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> jscr maths, dates, sources.
      <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

      Comment

      • Michael Winter

        #4
        Re: Date/Time Question

        Gord wrote on 18 Dec 2003 at Thu, 18 Dec 2003 16:06:36 GMT:
        [color=blue]
        > Many scripts and calendars call client side system time in order
        > to make presentations.
        >
        > However, the client's time may be improperly set, if set at all,
        > and/or the relevant time may be from another time zone.
        >
        > It would be of great value if the time of some central source
        > could be drawn, in the form of a ".js" file, into the script to
        > avoid dependence on the client's date/time.[/color]

        The best central source is the Time server network. However,
        JavaScript is unable to access such a resource. A Java applet or a
        server-side language (that includes a Time protocol or Sockets
        library) could with a bit of effort.
        [color=blue]
        > Please reply to may_NOSPAM_@eas tontario.com (remove the _NOSPAM_
        > part)[/color]

        Please read the FAQ for this group (http://jibbering.com/faq/),
        particularly the sixth paragraph of article 2.3.

        Mike

        --
        Michael Winter
        M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk")

        Comment

        • HikksNotAtHome

          #5
          Re: Date/Time Question

          In article <EoF9GzFfog4$Ew GB@merlyn.demon .co.uk>, Dr John Stockton
          <spam@merlyn.de mon.co.uk> writes:

          <--snip-->
          [color=blue][color=green]
          >>It would be of great value if the time of some central source could be
          >>drawn, in the form of a ".js" file, into the script to avoid
          >>dependence on the client's date/time.[/color]
          >
          >
          >The returned date/time needs to be GMT. For us, the best form would be
          >as a value of milliseconds since 1970-01-01 00:00:00 GMT, which can be
          >directly applied : var T = new Date(Number) or new Date(+String) .[/color]

          Doesn't all of it still depend on the clients clock being set correctly?
          Meaning, if local time is dependent on the users clock, and can be wrong, then
          any other time would inherently be wrong?

          I think what the OP wanted was some way to show what time it is, based on an
          accurate time source, irregardless of the users time settings.
          --
          Randy

          Comment

          • Dr John Stockton

            #6
            Re: Date/Time Question

            JRS: In article <20031218184739 .07578.00002220 @mb-m25.aol.com>, seen in
            news:comp.lang. javascript, HikksNotAtHome <hikksnotathome @aol.com>
            posted at Thu, 18 Dec 2003 23:47:39 :-[color=blue]
            >In article <EoF9GzFfog4$Ew GB@merlyn.demon .co.uk>, Dr John Stockton
            ><spam@merlyn.d emon.co.uk> writes:
            >
            ><--snip-->
            >[color=green][color=darkred]
            >>>It would be of great value if the time of some central source could be
            >>>drawn, in the form of a ".js" file, into the script to avoid
            >>>dependence on the client's date/time.[/color]
            >>
            >>
            >>The returned date/time needs to be GMT. For us, the best form would be
            >>as a value of milliseconds since 1970-01-01 00:00:00 GMT, which can be
            >>directly applied : var T = new Date(Number) or new Date(+String) .[/color]
            >
            >Doesn't all of it still depend on the clients clock being set correctly?
            >Meaning, if local time is dependent on the users clock, and can be wrong, then
            >any other time would inherently be wrong?
            >
            >I think what the OP wanted was some way to show what time it is, based on an
            >accurate time source, irregardless of the users time settings.[/color]


            If one can import a current value for milliseconds since 1970-01-01
            00:00:00 GMT, one can use it in at least two ways.

            One can check that new Date() gives the same within some reasonable
            tolerance, allowing for time taken to do the importing, and if they
            differ by more than, say, 15000, do alert("I say, could your clock be
            wrong?").

            Or one can note the difference, and add it to the result of any
            subsequent new Date() operation.


            One can then show GMT as-it-is (relying on user's clock rate); a page
            cannot show user's local time without relying on the user's zone
            settings.

            Since at a given instant there can be no more than 25 (hourly zones
            -12..+12) + about 2 (zones wrong side of Line) + about 10 (fractional
            hour offsets) correct readings for a local-time clock, a Web page
            could however show them all. Just load the strings into the box of
            <URL:http://www.merlyn.demo n.co.uk/js-date5.htm#SLHGD >.


            AIUI, under standard conditions, a Web page (using HTML, javascript and
            no more) obtained from domain A cannot read explicit data from arbitrary
            domain B - e.g. as author I can frame or pop-up (?) a page of yours, but
            I cannot read its words. I could, however, ask the reader to
            copy'n'paste the date/time string off your page into my input control.

            How, then, can such a page transfer a number from a co-operating alien
            domain into a javascript variable? For time, to the second, one needs
            32 bits; 8 Hex characters.

            ISTM that script may be able to determine the size of an alien graphic?
            If so, load 4 alien GIFs showing blankness, each of whose height and
            width together encode 2 hex digits - max size only 15/16 square - and
            decode.

            Or make 32 requests http://X.Y.Z?n for n = 0..31, with only those for
            which the current time has a 1 bit giving a response??



            To avoid rollover uncertainty, gray-code the underlying 32 bits, which
            also Grey-codes the Hex.

            All untested.

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