By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,504 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,504 IT Pros & Developers. It's quick & easy.

view server time

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.