Gettime ??? for displaying server time on browser

A

Assortments

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()%>
 
B

Bullschmidt

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

Evertjan.

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>

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top