473,395 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

sorry for this trivial question about dates

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
Jul 20 '05 #1
12 3502
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)
Jul 20 '05 #2
JRS: In article <Xk**************@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.
Jul 20 '05 #3
In message <Xn********************@194.109.133.29>, Evertjan.
<ex**************@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
--
David Lindsay
anti spam in force use reply to address
Jul 20 '05 #4
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+=6 0*60*1000;
if((d>summertimestart04)&&(d<summertimeend04))d+=6 0*60*1000;
if((d>summertimestart05)&&(d<summertimeend05))d+=6 0*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>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #5
JRS: In article <Xn********************@194.109.133.29>, seen in
news:comp.lang.javascript, Evertjan. <ex**************@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.
Jul 20 '05 #6
JRS: In article <j5**************@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>.

--
© 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.
Jul 20 '05 #7
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.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #8
JRS: In article <Xn********************@194.109.133.29>, seen in
news:comp.lang.javascript, Evertjan. <ex**************@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?
Jul 20 '05 #9
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.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #10
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 !

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #11
JRS: In article <Xn*******************@194.109.133.29>, seen in
news:comp.lang.javascript, Evertjan. <ex**************@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&mo del=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. ©
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.
Jul 20 '05 #12
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&mo del=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 !
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bml | last post by:
Is "Trivial constructor" either a default constructor generated by compiler or the one you write but it does nothing (empty inside method definition)? Is it required by C++ standard to bypass...
9
by: Michael Burtenshaw | last post by:
I would like to make a slide show using random images. The problem is my host is 250.com, and they don't support cgi-programs. Is there another way to accomplish random images?
11
by: sneill | last post by:
I have read a number of posts on the use of eval() in Javascript, and I agree that its use is questionable. But it does beg the following question: "How arbitrary does a string need to be before...
3
by: baibaichen | last post by:
hi, i am reading a C++ book, it mentions a term non-trivial object. what i understand is: if a object has: a) trivial constructor b) trivial assignment operator c) trivial destructor then it...
1
by: tkpmep | last post by:
I expected the following code to work: f = file(fn,"wb") writer = csv.writer(f) for i in range(IMax): writer.writerow(].append( for j in range(N)])) but instead i got the following error...
5
by: John | last post by:
I have 2 tables, one with dates and information about those dates, and one with people information. I want to create a report listing each date and the people who attended on that date (who have...
8
by: Trev | last post by:
Hi, If I had a string denoted by MyArray, how would I extract the number in brackets for use in the programme later on? I've tried "\" but all I get is a syntax error. What would be the usage for...
4
by: jobs | last post by:
1. How do I pass a subroutine a reference of an object? For example I have variable datef type datetime. I want to pass to pass datef the variable, not it's value to the sub? 2. In ADO.NET,...
4
by: pbd22 | last post by:
Hi. I am wondering what do I replace the "this" statement with to get the appropriate container/response. When I try: cal.prototype.dates(cal.days.day); I get
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.