view server time

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

    view server time

    Is it possible to display the current time directly from the server,
    and not client-side...I have people in different time zones trying to
    view the same page and the times (based on client) are coming up
    different.

    Thanks.
  • Evertjan.

    #2
    Re: view server time

    john wrote on 02 sep 2003 in comp.lang.javas cript:[color=blue]
    > Is it possible to display the current time directly from the server,
    > and not client-side...I have people in different time zones trying to
    > view the same page and the times (based on client) are coming up
    > different.[/color]

    1 by serverside code (ASP: Time is <%=now%> )

    2 by "GET"-ing the header:

    <script type="text/javascript">
    var xmlhttp = new ActiveXObject(" Msxml2.XMLHTTP" );
    xmlhttp.open("G ET", "http://www.qwerty.com/", false);
    xmlhttp.send();
    alert(xmlhttp.g etAllResponseHe aders().replace (/^(.*)[\s\S]*/,"$1"));
    </script>




    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • Dr John Stockton

      #3
      Re: view server time

      JRS: In article <3a3d008.030902 0800.434bddf0@p osting.google.c om>, seen
      in news:comp.lang. javascript, john <jbenson@gtcoca lcomp.com> posted at
      Tue, 2 Sep 2003 09:00:46 :-[color=blue]
      >Is it possible to display the current time directly from the server,
      >and not client-side...I have people in different time zones trying to
      >view the same page and the times (based on client) are coming up
      >different.[/color]

      I expect so.

      With php or asp or whatever, you might write the server time into the
      page before service, and read it with javascript after service, noting
      the difference between it and the user clock.

      OTOH, if you can assume either that the clients are correctly set for
      their localities, you can in pure javascript use the GMT/UTC time
      functions.

      For any application using different zones, GMT should be used as the
      prime date/time record.

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

      Working...