Daz wrote on 13 jul 2007 in comp.lang.javascript
:
Quote:
Thanks for the URLs, they are very helpful. I think I am going to look
into a PHP solution which others can use, which will send a JavaScript
object/array containing information about a particular time zone, such
as if DST is currently used, when the clock goes back/forward next,
and when.
>
On the serverside, using asp:
I have websites for the Netherlands on servers in Toronto,
so I use this conversion include,
using serverside j[ava]script to determine the timeoffset,
and vbscript for the rest.
I do no need any knowledge about Canadian DST switch data/times,
and Central European Time quirks are wellknown over here.
Now is Toronto local time.
nuGMT is UTC.
nu is Central European local time.
nudag is the local time string.
===========================================
<% ' vbscript
nuGMT = DateAdd("h", TimezoneOffset, Now)
nu = DateAdd("h", 1, nuGMT)
If nuGMT>#2007-03-25 01:00# then nu = DateAdd("h", 2, nuGMT)
If nuGMT>#2007-10-28 01:00# then nu = DateAdd("h", 1, nuGMT)
If nuGMT>#2008-03-30 01:00# then nu = DateAdd("h", 2, nuGMT)
If nuGMT>#2008-10-26 01:00# then nu = DateAdd("h", 1, nuGMT)
nudag = day(nu) & "/" & month(nu) & " " & right("0"&hour(nu),2) & ":" &
right("0"&minute(nu),2) & ":" & right("0"&second(nu),2)
%>
<script language='jscript' runat='server'>
var TimezoneOffset = new Date().getTimezoneOffset()/60;
</script>
===========================================
John Stockton wrote a computed European switch rule code here:
http://groups.google.com/group/comp.lang.javascript/msg/858cf852a991445c>
In js-date5.htm (M=3 or M=10) :
function EUch(Y, M) { // return ms of Spring/Autumn EU clock change
var J = Date.UTC(Y, M-1, 31) // last of month is 31st, get UTC
return J - 864e5*((4+J/864e5)%7) + 36e5 /* Sun, 0100 GMT, ms */
}
[Not tested now]
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)