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

Gettime ??? for displaying server time on browser

P: n/a
I'm trying to display the server time on the local browser, just as
http://www.time.gov does it.

Is there any sample code for JS or VB available?

TIA,
Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
becuase asp runs on the server and publishes the page to the client
this will show you the time from the server.
<%=time()%>
or
<%=Now()%>
"Matthew Ferri" <ma***********@worldnet.att.net> wrote in message
news:xm******************@bgtnsc04-news.ops.worldnet.att.net...
I'm trying to display the server time on the local browser, just as
http://www.time.gov does it.

Is there any sample code for JS or VB available?

TIA,

Jul 22 '05 #2

P: n/a
Something like this has worked for me:

mintServerToOrgHourOffset = 1 ' Server is Mountain Time and org is
Central Time.

mvarOrgCurDtTime = DateAdd("H", mintServerToOrgHourOffset, Now())

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 22 '05 #3

P: n/a
Matthew Ferri wrote on 23 jan 2005 in
microsoft.public.inetserver.asp.general:
I'm trying to display the server time on the local browser, just as
http://www.time.gov does it.

Is there any sample code for JS or VB available?


This gives running local time with server precision,
irrespective of the server local timezone:
[weekdays in Dutch and dd-mm-yyyy]

=======================================

<script runat=server language=javascript>
ds = new Date();
ds=ds*1;
</script>

<script type='text/javascript'>
ds= <% =ds %>; // UTC server
dc=new Date();
dc=dc*1; // UTC client
dif = ds-dc; // UTC difference

//alert(dif+' is the milliseconds UTC error between server and client')

function two(x){
return ((x<10)?"0":"")+x
}

var wkdgn=["zon","maan","dins","woens","donder","vrij","zater "]

function settijd(){
d = new Date()
d=new Date(d*1+dif);
document.getElementById('tijd').innerHTML=""+
wkdgn[d.getDay()]+"dag "+
two(d.getDate())+"-"+two(d.getMonth()+1)+"-"+d.getYear()+
"<br> <span style='font-size:22pt;font-weight:800;'>"+
two(d.getHours())+":"+two(d.getMinutes())+":"+
two(d.getSeconds())+"</span>"
setTimeout("settijd()",1000)
}

</script>

<body onload='settijd()'>
<div id='tijd'></div>

==================================

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.