469,327 Members | 1,323 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

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.
Jul 20 '05 #1
2 6041
john wrote on 02 sep 2003 in comp.lang.javascript:
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.


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("GET", "http://www.qwerty.com/", false);
xmlhttp.send();
alert(xmlhttp.getAllResponseHeaders().replace(/^(.*)[\s\S]*/,"$1"));
</script>


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2
JRS: In article <3a*************************@posting.google.com> , seen
in news:comp.lang.javascript, john <jb*****@gtcocalcomp.com> posted at
Tue, 2 Sep 2003 09:00:46 :-
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.


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.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Neil | last post: by
19 posts views Thread by Lyle Fairfield | last post: by
3 posts views Thread by Philip Tripp | last post: by
12 posts views Thread by Raed Sawalha | last post: by
104 posts views Thread by Beowulf | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.