469,645 Members | 1,634 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

ASP time in GMT

Abs
Hello,

I've used this ASP funtion to display the time on my web page:

Date: <%= FormatDateTime(Date, 1)%>
Time: <%= FormatDateTime(now, 4)%>

THis was working fine until i moved my site to a server based in the states,
not the time is 5hrs behind. Can anyone help me resolve this??

Many thanks.

Abs
Mar 13 '07 #1
5 12140
Abs wrote on 13 mrt 2007 in microsoft.public.inetserver.asp.general:
Hello,

I've used this ASP funtion to display the time on my web page:

Date: <%= FormatDateTime(Date, 1)%>
Time: <%= FormatDateTime(now, 4)%>

THis was working fine until i moved my site to a server based in the
states, not the time is 5hrs behind. Can anyone help me resolve
this??
It would be usefull if you told us your timezone!

This topic was posted by me yesterday in his NG,

The server being in Toronto [Now],
the result in Central European Time [nowCET].
==================================
<%
nowGMT = DateAdd("h", TimezoneOffset, Now)
nowCET = DateAdd("h", 1, nowGMT)
If nowGMT>#2007-03-25 01:00# Then nowCET = DateAdd("h",2,nowGMT)
If nowGMT>#2007-10-28 01:00# Then nowCET = DateAdd("h",1,nowGMT)
If nowGMT>#2008-03-30 01:00# Then nowCET = DateAdd("h",2,nowGMT)
If nowGMT>#2008-10-26 01:00# Then nowCET = DateAdd("h",1,nowGMT)
%>

<script language='javascript' runat='server'>
var TimezoneOffset = new Date().getTimezoneOffset()/60;
</script>
===========================================
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 13 '07 #2
Abs wrote:
Hello,

I've used this ASP funtion to display the time on my web page:

Date: <%= FormatDateTime(Date, 1)%>
Time: <%= FormatDateTime(now, 4)%>

THis was working fine until i moved my site to a server based in the states,
not the time is 5hrs behind. Can anyone help me resolve this??

Many thanks.

Abs

http://classicasp.aspfaq.com/date-ti...-gmt-time.html
Mike
Mar 13 '07 #3
ASP runs on the server and will return server time. If you want local time of the user to be displayed on the page you can use
client side javascript .

"Abs" <no**********@email.comwrote in message news:%2****************@TK2MSFTNGP03.phx.gbl...
Hello,

I've used this ASP funtion to display the time on my web page:

Date: <%= FormatDateTime(Date, 1)%>
Time: <%= FormatDateTime(now, 4)%>

THis was working fine until i moved my site to a server based in the states, not the time is 5hrs behind. Can anyone help me
resolve this??

Many thanks.

Abs

Mar 14 '07 #4
Jon Paal [MSMD] wrote on 14 mrt 2007 in
microsoft.public.inetserver.asp.general:
"Abs" <no**********@email.comwrote in message
>THis was working fine until i moved my site to a server based in the
states, not the time is 5hrs behind. Can anyone help me resolve
this??
[Please do not toppost on usenet]
ASP runs on the server and will return server time. If you want local
time of the user to be displayed on the page you can use client side
javascript .
However, it is quite possible to add
trusted [ ;-) ] serverside time precision to that:

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

<script type='text/javascript'>

var ds = <% =ds %>; // numerical UTC server
var dc = new Date();
dc = dc*1; // numerical UTC client
var dif = ds-dc; // millisecs UTC difference
dif2 = Math.floor(-dif/1000)

document.write("Local clock error: " + dif2 + " sec.<br><br>");

d = new Date()

document.write("Client time being: " + d + "<br><br>");

d = new Date(d*1+dif);

document.write("Exact local time being: " + d );

</script>
============================

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 14 '07 #5
Abs
Thanks guys, probably use javascript.

"Evertjan." <ex**************@interxnl.netwrote in message
news:Xn********************@194.109.133.242...
Jon Paal [MSMD] wrote on 14 mrt 2007 in
microsoft.public.inetserver.asp.general:
>"Abs" <no**********@email.comwrote in message
>>THis was working fine until i moved my site to a server based in the
states, not the time is 5hrs behind. Can anyone help me resolve
this??

[Please do not toppost on usenet]
>ASP runs on the server and will return server time. If you want local
time of the user to be displayed on the page you can use client side
javascript .

However, it is quite possible to add
trusted [ ;-) ] serverside time precision to that:

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

<script type='text/javascript'>

var ds = <% =ds %>; // numerical UTC server
var dc = new Date();
dc = dc*1; // numerical UTC client
var dif = ds-dc; // millisecs UTC difference
dif2 = Math.floor(-dif/1000)

document.write("Local clock error: " + dif2 + " sec.<br><br>");

d = new Date()

document.write("Client time being: " + d + "<br><br>");

d = new Date(d*1+dif);

document.write("Exact local time being: " + d );

</script>
============================

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

Mar 14 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Szabolcs Nagy | last post: by
6 posts views Thread by Rebecca Smith | last post: by
3 posts views Thread by luscus | last post: by
reply views Thread by Edward Diener | last post: by
3 posts views Thread by cj | last post: by
1 post views Thread by davelist | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.