Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

sorry for this trivial question about dates

3 views
Skip to first unread message

David Lindsay

unread,
Sep 17, 2003, 4:35:58 PM9/17/03
to
I want to put date and time on my web page, and to be sure it tracks the
BST/ GMT changes.
Can anyone help me, I have gone back in my historic file for quite a
while and not found anything.
Sorry about the newbie trivial question
--
David Lindsay
anti spam in force use reply to address

Evertjan.

unread,
Sep 17, 2003, 5:57:32 PM9/17/03
to
David Lindsay wrote on 17 sep 2003 in comp.lang.javascript:

> I want to put date and time on my web page, and to be sure it tracks the
> BST/ GMT changes.
> Can anyone help me, I have gone back in my historic file for quite a
> while and not found anything.
> Sorry about the newbie trivial question

What do you mean by BST/ GMT changes ?

Time changes all the time. ;-)

Do you want the time in GMT/UTC or in west european time?

Do you want client time or server time ?

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

Dr John Stockton

unread,
Sep 18, 2003, 9:11:00 AM9/18/03
to
JRS: In article <Xkqc2DFuWMa$Ew...@sdresearch.com>, seen in
news:comp.lang.javascript, David Lindsay <sp...@use.reply-to.co.uk>
posted at Wed, 17 Sep 2003 21:35:58 :-

>I want to put date and time on my web page, and to be sure it tracks the
>BST/ GMT changes.
>Can anyone help me, I have gone back in my historic file for quite a
>while and not found anything.
>Sorry about the newbie trivial question

Try reading the newsgroup FAQ on the subject of dates and times.

I assume that you mean the current date and time.

If you want to be SURE of always being correct, you must yourself
include the current EU rules for the change, and update whenever
necessary (unlikely). At least one delivered version of Windows has the
rules for the UK wrong.

Putting the current local date & time is a pointless exercise; most OSs
already show it, most users know the date and can see a proper clock or
a watch.

There is a use for showing the current British time to foreigners; for
example to help Radio 2 listeners sited across the Channel.

For use in the EU, you only need to apply the correct fixed offset to
their local time; but for that you need their location, which can be
adequately deduced from new Date(0).getTimezoneOffset().

Otherwise, you need to implement the UK Rules, as in js-date5.htm#UKnow
function BritNow (uses EUch). Note that the UTC of the resulting Object
must be displayed; UTCDstr is in include3.htm, visible in js-nclds.htm

If you are only interested in readers whose computer uses UK time, and
can disregard possible OS errors, display the date object directly, but
do not use toLocaleString (it is wrong in my browser). Best to supply a
display routine such as ISOlocalDTstr (/loc cit/).

You should, of course, point out the dependence on the correctness of
the viewing computer's time adjustment.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.

David Lindsay

unread,
Sep 19, 2003, 9:55:56 AM9/19/03
to
In message <Xns93F9F3CA...@194.109.133.29>, Evertjan.
<exjxw.ha...@interxnl.net> writes

>David Lindsay wrote on 17 sep 2003 in comp.lang.javascript:
>
>> I want to put date and time on my web page, and to be sure it tracks the
>> BST/ GMT changes.
>> Can anyone help me, I have gone back in my historic file for quite a
>> while and not found anything.
>> Sorry about the newbie trivial question
>
>What do you mean by BST/ GMT changes ?
>
we change from GMT to British summer Time and back again every year

>
>Do you want the time in GMT/UTC or in west european time?

The actual time in the United Kingdom, as on the server.

>Do you want client time or server time ?
>

TIA

Evertjan.

unread,
Sep 19, 2003, 10:49:55 AM9/19/03
to
David Lindsay wrote on 19 sep 2003 in comp.lang.javascript:
> In message Evertjan wrote

>>> Sorry about the newbie trivial question
>>What do you mean by BST/ GMT changes ?
> we change from GMT to British summer Time and back again every year
>>Do you want the time in GMT/UTC or in west european time?
> The actual time in the United Kingdom, as on the server.

Wich is Western European time.

>>Do you want client time or server time ?
> TIA

If we are talking client coding:
If the client machine is correctly configured and has the correct time and is in the UK,
you can just take the javascript time functions, they are correct.

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

If we are talking server coding and the server has the correct time and is in the UK the
same applies.

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

if the server is somewhere else, say in Toronto, then you are in trouble. The swich
times are hours and sometimes a also week apart.

Serverside ASP javascript can deduct the actual UTC time.
For correction to Western European Summertime you can add one hour to UTC, but the
switch moment has to be hardcoded in your code, I presume.

Not tested, but try it out:

<script language=javascript runat=server>

summertimestart03 = Date.UTC(2003,3-1,30,1);
summertimeend03 = Date.UTC(2003,10-1,26,1);
// see <http://www.npl.co.uk/time/time_summer.html>

d = new Date();
if((d>summertimestart03)&&(d<summertimeend03))d+=60*60*1000;
if((d>summertimestart04)&&(d<summertimeend04))d+=60*60*1000;
if((d>summertimestart05)&&(d<summertimeend05))d+=60*60*1000;
c = ":";
s = d.getUTCHours() + c;
s += d.getUTCMinutes() + c;
s += d.getUTCSeconds() + c;
s += d.getUTCMilliseconds();

Response.write(s);

</script>

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

see for more help:

<http://www.merlyn.demon.co.uk/uksumtim.htm>

Dr John Stockton

unread,
Sep 19, 2003, 3:40:51 PM9/19/03
to
JRS: In article <Xns93FBAB3D...@194.109.133.29>, seen in
news:comp.lang.javascript, Evertjan. <exjxw.ha...@interxnl.net>
posted at Fri, 19 Sep 2003 14:49:55 :-

>David Lindsay wrote on 19 sep 2003 in comp.lang.javascript:
>> In message Evertjan wrote
>>>> Sorry about the newbie trivial question
>>>What do you mean by BST/ GMT changes ?

UK civil time is identical to Dutch, except that good Dutch clocks are
*always* an hour ahead of ours.

>> we change from GMT to British summer Time and back again every year
>>>Do you want the time in GMT/UTC or in west european time?
>> The actual time in the United Kingdom, as on the server.
>
>Wich is Western European time.

You might call it that; we do not! What do you call the Dutch and
Graeco-Finnish time zones in Europe?

>if the server is somewhere else, say in Toronto, then you are in trouble. The
>swich
>times are hours and sometimes a also week apart.

No problem. It's all done somewhere on my site; if Toronto time is not
New York time (the map in my diary is *small*, just change 5 to 6)

>Serverside ASP javascript can deduct the actual UTC time.
>For correction to Western European Summertime you can add one hour to UTC, but
>the
>switch moment has to be hardcoded in your code, I presume.

Indeed not. 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 */ }

Valid for all years and all of the EU under present rules.

I've not consolidated the NA code to that extent, but it includes

var DSTon = (new Date(Date.UTC(Yr, 03, 07, 2-TZ))).toSunday()
var DSTof = (new Date(Date.UTC(Yr, 09, 31, 1-TZ))).toSunday()

with
Date.prototype.toSunday = new Function( // back by 0-6 days
'return new Date(this.setDate(this.getDate()-this.getDay()))')

For NY (& To?), TZ=-5.

<URL:http://www.merlyn.demon.co.uk/js-date5.htm#DDTA> does it for
anywhere, al long as a suitable TZ string can be provided. Tel Aviv
might be difficult.

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

Dr John Stockton

unread,
Sep 19, 2003, 3:50:01 PM9/19/03
to
JRS: In article <j5qBxnBsrwa$Ew...@sdresearch.com>, seen in
news:comp.lang.javascript, David Lindsay <mu...@use.reply-to.co.uk>
posted at Fri, 19 Sep 2003 14:55:56 :-

>>Do you want the time in GMT/UTC or in west european time?
>
>The actual time in the United Kingdom, as on the server.

AIUI, servers generally run on GMT, even in outlandish places like other
countries, and even in the Summer. It is not a server's business to
care where its clients are or think they are. AIUI, there is, for
example, a piece of the British Mainland that operates on Paris time.

It seems clear that you want to display, to a correctly-set user
anywhere in the world, the time we use here - UK Civil Time.

Give or take a quibble about whether UK Civil Time is or should be UTC
or GMT. I think the best UK clocks show UTC, but legally Summer Time
starts/stops by GMT. It may have changed.


function BritNow(Now) { // gives UTC with UK time numbers
var yr = Now.getUTCFullYear()
var EUSTon = EUch(yr, 03), EUSTof = EUch(yr, 10)
// abroad: add winter TZ offset; update change rules if not EU
var ms = Now.getTime() // GMT
if ((ms>=EUSTon) && (EUSTof>ms)) ms += 3600000 // +1h
return new Date(ms) }

function TryBritNow() { document.writeln(
'<table summary="British Date"',
' bgcolor=#FFA500 align=center cellpadding=10>',
'<tr><td>Page shown at ',
BritNow(new Date()).UTCDstr(), ' British civil time,',
' by your clock.<\/td><\/tr><\/table>') }

which drives <URL:http://www.merlyn.demon.co.uk/js-date5.htm#UKNow>.

--

Evertjan.

unread,
Sep 20, 2003, 4:48:24 AM9/20/03
to
Dr John Stockton wrote on 19 sep 2003 in comp.lang.javascript:
> UK civil time is identical to Dutch, except that good Dutch clocks are
> *always* an hour ahead of ours.
>
>>> we change from GMT to British summer Time and back again every year
>>>>Do you want the time in GMT/UTC or in west european time?
>>> The actual time in the United Kingdom, as on the server.
>>
>>Wich is Western European time.
>
> You might call it that; we do not! What do you call the Dutch and
> Graeco-Finnish time zones in Europe?

There is no Dutch time zone nowadays!

Europe ["The union as we know it"] has three time zones:

Western European Time
Central European Time
Eastern European Time

If you want to call your time "British standard time" or "London time" ot
"Travalgar square time", so be it, but those are only local names of the
same, these are leftover names from the time when local time was
different in each town or count(r)y, and railway time was another time
again.

Any question about time zone manipulation code on an internationally used
NG should address the whole of the time zone and not just such a local
name.

I, as an European, am proud the Europen times switches to and from
summertime (US: daylight saving time) at the same absolute time, 01:00
UTC, and not like the North American system where the switch ripples
through the continent, and interstate travel on those nights sould be an
exact local time loving exentric's nightmare. In eastern British Columbia
the time zone border runs through the province with roadside notices
warning you on an very irregular basis. In other places I suppose it is
the same.

>>if the server is somewhere else, say in Toronto, then you are in

>>trouble. The swich times are hours and sometimes also a week apart.

The nice thing about serverside javascript is that you can get to UTC
immediately, or detect the servers time zone difference.

Serverside vbscript does not have these options, so if you have a server
in Toronto and want to go to UTC or one of the three European times, you
would have to incorporate the Toronto local (EST?) switch times.

> No problem. It's all done somewhere on my site; if Toronto time is
> not New York time (the map in my diary is *small*, just change 5 to 6)

> [ .... etc ... ]

That is why I put a link to your site in my posting, John, your solutions
are by far the most extensive and well tested.

Dr John Stockton

unread,
Sep 20, 2003, 1:03:52 PM9/20/03
to
JRS: In article <Xns93FC6DF7...@194.109.133.29>, seen in
news:comp.lang.javascript, Evertjan. <exjxw.ha...@interxnl.net>
posted at Sat, 20 Sep 2003 08:48:24 :-

>
>I, as an European, am proud the Europen times switches to and from
>summertime (US: daylight saving time) at the same absolute time, 01:00
>UTC, and not like the North American system where the switch ripples
>through the continent, and interstate travel on those nights sould be an
>exact local time loving exentric's nightmare. In eastern British Columbia
>the time zone border runs through the province with roadside notices
>warning you on an very irregular basis. In other places I suppose it is
>the same.

There may be problems when the EU eventually fills Europe; that needs
another two zones, and if the change remains at 1 am UTC it will in the
autumn be at 6 am local time by the Asian Border. And Central European
Time will no longer be in the middle; we shall be no better than those
who have the Mid-West well to the East of centre.

But you may not be quite right in saying that the whole EU changes
clocks simultaneously. Brussels has, I agree, said 01:00 UTC; but I
think that the corresponding UK document may put the changes at 01:00
GMT - which can differ by up to 0.9 seconds.

Does anyone know what the 10 (?) about-to-join countries do about Summer
Time?

-

Site editors : mtr -x+ -o/~ *.htm - "this\s+that\s+tother" lists all
files not containing that phrase, whatever the whitespace

--

© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©

Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
I find MiniTrue useful for viewing/searching/altering files, at a DOS prompt;
free, DOS/Win/UNIX, <URL:http://www.idiotsdelight.net/minitrue/> Update soon?

Evertjan.

unread,
Sep 20, 2003, 6:41:10 PM9/20/03
to
Dr John Stockton wrote on 20 sep 2003 in comp.lang.javascript:
> But you may not be quite right in saying that the whole EU changes
> clocks simultaneously. Brussels has, I agree, said 01:00 UTC; but I
> think that the corresponding UK document may put the changes at 01:00
> GMT - which can differ by up to 0.9 seconds.

I certainly doubt that. The UK specs only differ from the rest if it is in
the political interest of the uk government to take the trouble, such as in
the case of the euro, and 0.9 seconds does not win votes in any local
election.

Or the legislators did not know of any difference between GMT and UTC.

40000000 meter x cos 52deg = 24626459 meters
1 day = 86400 seconds
1 second = 285 meter
0.9 second = 256 meter

So the meridian at Greenwich moves a maximum of 256 meters in the maimum
time difference between UTC and GMT. That cannot be acepted ! The Eurostar
would make a big jump between France and the UK, endangering the many
pedestrian illegal immigrants. Talking of tunnel vision.

Evertjan.

unread,
Sep 20, 2003, 6:49:11 PM9/20/03
to
Dr John Stockton wrote on 20 sep 2003 in comp.lang.javascript:

> But you may not be quite right in saying that the whole EU changes
> clocks simultaneously. Brussels has, I agree, said 01:00 UTC; but I
> think that the corresponding UK document may put the changes at 01:00
> GMT - which can differ by up to 0.9 seconds.
>

UK law 1997:
<http://webexhibits.org/daylightsaving/uk.html>

EU law 2000:
<http://webexhibits.org/daylightsaving/eu.html>

Both say GMT !

Dr John Stockton

unread,
Sep 21, 2003, 5:24:56 PM9/21/03
to
JRS: In article <Xns93FD863...@194.109.133.29>, seen in
news:comp.lang.javascript, Evertjan. <exjxw.ha...@interxnl.net>
posted at Sat, 20 Sep 2003 22:49:11 :-

>Dr John Stockton wrote on 20 sep 2003 in comp.lang.javascript:
>
>> But you may not be quite right in saying that the whole EU changes
>> clocks simultaneously. Brussels has, I agree, said 01:00 UTC; but I
>> think that the corresponding UK document may put the changes at 01:00
>> GMT - which can differ by up to 0.9 seconds.
>>
>
>UK law 1997:
><http://webexhibits.org/daylightsaving/uk.html>
>
>EU law 2000:
><http://webexhibits.org/daylightsaving/eu.html>

They are, I believe, American; they are certainly not authoritative; but
they may be right.

<http://www.dti.gov.uk/er/sumtimetb.htm>, updated 20 March 2003, uses
GMT. It links to <http://europa.eu.int/smartapi/cgi/sga_doc?smartapi!ce
lexapi!prod!CELEXnumdoc&lg=EN&numdoc=32000L0084&model=guichett> of 19
January 2001 which uses GMT. Those are authoritative.

But <http://www.merlyn.demon.co.uk/uksumtim.htm> has noted that
"Statements about the EU rules are derived from the English version
(which uses GMT; others do not)."



--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©

Evertjan.

unread,
Sep 22, 2003, 3:29:41 AM9/22/03
to
Dr John Stockton wrote on 21 sep 2003 in comp.lang.javascript:
>>UK law 1997:
>><http://webexhibits.org/daylightsaving/uk.html>
>>
>>EU law 2000:
>><http://webexhibits.org/daylightsaving/eu.html>
>
> They are, I believe, American; they are certainly not authoritative;
> but they may be right.
>
> <http://www.dti.gov.uk/er/sumtimetb.htm>, updated 20 March 2003, uses
> GMT. It links to
> <http://europa.eu.int/smartapi/cgi/sga_doc?smartapi!ce
> lexapi!prod!CELEXnumdoc&lg=EN&numdoc=32000L0084&model=guichett> of 19
> January 2001 which uses GMT. Those are authoritative.
>
> But <http://www.merlyn.demon.co.uk/uksumtim.htm> has noted that
> "Statements about the EU rules are derived from the English version
> (which uses GMT; others do not)."

Such laws or regulations should refer to UTC, IMHO.

On the other hand, is the exactness of legal local time within one
second that important?

Any serious scientific time measurement on that level of tolerance
should be in UTC.

Imagine a police officer saying: "You are not using your headlights at
night and it night since is 0.9 seconds". That would be zero-tolerance !

0 new messages