473,770 Members | 4,718 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GMT Date Format Anomaly

When the following code is run on Sat Dec 25 2004 19:54:18 GMT-0600 (Central
Standard Time)

var today = new Date();
var GMTDate = today.toGMTStri ng();
document.write( "GMTDate: " + GMTDate);

The code returns:
Sun, 26 Dec 2004 19:54:18 GMT (the next day after the code was actually run)

Please advise why the day is in the future and suggest how to get the
correct GMT date format.

<%= Clinton Gallagher
Jul 23 '05
17 2516
JRS: In article <cq************ *******@news.de mon.co.uk>, dated Tue, 28
Dec 2004 16:05:17, seen in news:comp.lang. javascript, Mark Preston
<us****@nosourc e.co.uk> posted :
clintonG wrote:
So-called 'we support standards' FireFraud 0.9.3 returns the text GMT in the
string returned by the toUTCString method but the 'evil' IE returns UTC as
expected.

There is no defined output format for UTC (which is an *internal* means
of representing time set at GMT for general use - pureply "cosmetic") .
The correct display format in ALL cases will be "GMT" and that is what
you should see.


There is at least one browser still in use in which
new Date() -> Tue Dec 28 20:42:00 UTC 2004
new Date().toGMTStr ing() -> Tue, 28 Dec 2004 20:42:52 UTC
new Date().toUTCStr ing() -> Tue, 28 Dec 2004 20:43:28 UTC
new Date().toLocale String() -> 12/28/2004 20:44:14
with UK localisation.

The wise programmer will allow for getting either UTC or GMT (and know
that the two are not synonymous, and in principle neither is correct).
AFAIK, however, one need not expect utc or gmt.

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

The wise programmer will allow for getting either UTC or GMT (and know
that the two are not synonymous, and in principle neither is correct).
AFAIK, however, one need not expect utc or gmt.

The wise reader will also know that GMT and UTC are the same thing.
Unfortunately, as we all know, wise readers are as rare as rocking-horse
droppings... :)
Jul 23 '05 #12
"Mark Preston" <us****@nosourc e.co.uk> wrote in message
news:cr******** ***********@new s.demon.co.uk.. .
Dr John Stockton wrote:

The wise programmer will allow for getting either UTC or GMT (and know
that the two are not synonymous, and in principle neither is correct).
AFAIK, however, one need not expect utc or gmt.

The wise reader will also know that GMT and UTC are the same thing.
Unfortunately, as we all know, wise readers are as rare as rocking-horse
droppings... :)


GMT vs. UTC
http://sts.sunyit.edu/timetech/gmt-utc.html

The development of highly accurate cesium-beam atomic clocks led to the
redefinition of the second in 1967. This led to the recognition by
scientists and technologists of the inadequacy of measuring time based on
the erratic motion of the earth whose rate fluctuates by a few thousandths
of a second a day. Attempts to couple GMT, based on the earth's motion, and
the new definition of the second was highly unsatisfactory. A compromise
time scale, Coordinated Universal Time (UTC), was devised and became
effective on January 1, 1972.

GMT vs. UTC
http://people.etango.com/~markm/arch...mt_vs_utc.html

Last night at dinner a tangential conversation got us on the topic of GMT
vs. UTC. None of us knew the exact difference between the two except for
that UTC was newer and more exact. So, I looked it up. Here is a good, brief
description from the State University of New York Institute of Technology's
Science & Technology Society (man that is a mouthful). Basically it comes
down to GMT being based on the rotation of the earth around its axis and the
sun (which isn't completely regular) and UTC being based on a Cesium atomic
clock (which is far more accurate and regular). UTC is regularly modified
with "leap seconds" so that it matches up to GMT to be the standard for
date/time stamps. Also, UTC is the authoriative measurement for calculations
involving duration.

Update: Corrected, which unit gets leap seconds added. Thanks Daniel for
pointing out my mistake.
Jul 23 '05 #13
JRS: In article <cr************ *******@news.de mon.co.uk>, dated Fri, 31
Dec 2004 12:22:24, seen in news:comp.lang. javascript, Mark Preston
<us****@nosourc e.co.uk> posted :
Dr John Stockton wrote:

The wise programmer will allow for getting either UTC or GMT (and know
that the two are not synonymous, and in principle neither is correct).
AFAIK, however, one need not expect utc or gmt.

The wise reader will also know that GMT and UTC are the same thing.
Unfortunatel y, as we all know, wise readers are as rare as rocking-horse
droppings... :)

No, GMT and UTC are not the same thing, even apart from what I was
referring to, which is that a coder must allow for the possibility of
getting either string from a Date Object method.

Javascript treats them as synonymous, and implements time as GMT; few
computers have the information needed to implement UTC.

GMT has 24 * 60 * 60 seconds in EVERY day [@], but the seconds are of
slightly varying length so that, on average, GMT Noon is at mid-day at
Greenwich.

UTC has 24 * 60 * 60 SI seconds in most days, and the seconds are of
constant length[+], but occasionally there can be one added or omitted,
so that, on average, UTC Noon is at mid-day at Greenwich.

Those are a sort of average mid-day - look up "Equation of Time".

The difference between UTC and GMT is kept under, IIRC, 0.9 seconds.

Above, UTC means UTC; but IIRC GMT above may mean some other timescale,
perhaps UT, with similar properties - GMT itself being now deprecated.

See <URL:http://www.merlyn.demo n.co.uk/leapsecs.htm>, etc.
The above is not precision-grade; for that, refer to such as NPL, NIST,
and "The International Earth Rotation Service (IERS)" at
<URL:http://hpiers.obspm.fr/>.

The advantage of GMT, as a term, is that it is generally interpreted as
needed, with days each containing 86400 parts; as opposed to UTC, where
each day contains 86400+-1 SI seconds. Javascript has no support for
Leap Seconds. It accepts new Date("2005/06/30 23:59:59 UTC") here as
nearly Jul 1 0100h, but considers new Date("2005/06/30 23:59:60 UTC")
as meaning NaN, whereas that second *may* occur.
Be aware that, unless recently changed, UK legal time is GMT, but time
signals here are UTC. The cautious drinker will prudently drain his
glass at least 0.9 seconds before the stipulated moment seems to appear;
and it would be interesting to argue on such a basis about a marginal
case of Ken Livingstone's congestion charge.

[@] Except 1924 Dec 31 GMT or 1925 Jan 1 GMT.

[+] La seconde est la duree de 9 192 631 770 periodes
de la radiation correspondant a la transition entre les deux
niveaux hyperfins de l'etat fondamental de l'atome de cesium 133
(CGPM 13, 1967, Resolution 1). [Francophones add accents to taste.]

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 23 '05 #14
Dr John Stockton wrote:
JRS: In article <cr************ *******@news.de mon.co.uk>, dated Fri, 31
Dec 2004 12:22:24, seen in news:comp.lang. javascript, Mark Preston
<us****@nosourc e.co.uk> posted :
Dr John Stockton wrote:
The wise programmer will allow for getting either UTC or GMT (and know
that the two are not synonymous, and in principle neither is correct).
AFAIK, however, one need not expect utc or gmt.


The wise reader will also know that GMT and UTC are the same thing.
Unfortunately , as we all know, wise readers are as rare as rocking-horse
droppings.. . :)


No, GMT and UTC are not the same thing, even apart from what I was
referring to, which is that a coder must allow for the possibility of
getting either string from a Date Object method.

Technically, you are correct. GMT is a standard-period time recording
(that is, it counts how long the Earth takes to revolve) and is
consequently "inaccurate " since nothing in this life is as simple as a
spinning planet is assumed to be. UTC, on the other hand, is a derived
probabilistic decay-rate measurement.

But, be honest, who really cares about the odd leap-second or so?
Jul 23 '05 #15
JRS: In article <cr************ *******@news.de mon.co.uk>, dated Mon, 3
Jan 2005 16:31:02, seen in news:comp.lang. javascript, Mark Preston
<us****@nosourc e.co.uk> posted :
Dr John Stockton wrote:
JRS: In article <cr************ *******@news.de mon.co.uk>, dated Fri, 31
Dec 2004 12:22:24, seen in news:comp.lang. javascript, Mark Preston
<us****@nosourc e.co.uk> posted :
Dr John Stockton wrote:

The wise programmer will allow for getting either UTC or GMT (and know
that the two are not synonymous, and in principle neither is correct).
AFAIK, however, one need not expect utc or gmt.
The wise reader will also know that GMT and UTC are the same thing.
Unfortunatel y, as we all know, wise readers are as rare as rocking-horse
droppings. .. :)
No, GMT and UTC are not the same thing, even apart from what I was
referring to, which is that a coder must allow for the possibility of
getting either string from a Date Object method.

Technically, you are correct. GMT is a standard-period time recording
(that is, it counts how long the Earth takes to revolve) and is
consequently "inaccurate " since nothing in this life is as simple as a
spinning planet is assumed to be.


Approximately correct.
UTC, on the other hand, is a derived
probabilisti c decay-rate measurement.
Total rubbish. It has nothing at all to do with decay rates. UTC is
based on the SI second, which is based on a precise transition of Cs-133
(see footnote [+] to my previous article), plus adjustments to make it
agree with one of the GMT-class time scales to within 0.9 seconds.

See my WWW site, and confirm by means of the links it contains; do not
trust amateur sources.
But, be honest, who really cares about the odd leap-second or so?


Quite a number of people care quite a lot - granted, only a minority
know, but many more could be affected if a mistake were made.
The important things for this group remain that (a) one can never be
really safe in assuming that a string generated by the javascript
processor will not include GMT where UTC might be expected, or /vice
versa/, (b) javascript knows nothing of leap seconds, and behaves
arithmetically as GMT does.

--
© John Stockton, Surrey, UK. *@merlyn.demon. co.uk / ??*********@phy sics.org ©
Web <URL:http://www.merlyn.demo n.co.uk/> - FAQish topics, acronyms, & links.
Correct <= 4-line sig. separator as above, a line precisely "-- " (SoRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SoRFC1036)
Jul 23 '05 #16
Dr John Stockton wrote:
JRS: In article <cr************ *******@news.de mon.co.uk>, dated Mon, 3
Jan 2005 16:31:02, seen in news:comp.lang. javascript, Mark Preston
<us****@nosourc e.co.uk> posted :
UTC, on the other hand, is a derived
probabilist ic decay-rate measurement.


Total rubbish. It has nothing at all to do with decay rates. UTC is
based on the SI second, which is based on a precise transition of Cs-133
(see footnote [+] to my previous article), plus adjustments to make it
agree with one of the GMT-class time scales to within 0.9 seconds.

See my WWW site, and confirm by means of the links it contains; do not
trust amateur sources.

Umm - yes, it is. But as I just pointed out in one sentance exactly the
same thing I don't see your problem.

In case you are not sure why they are the same then I suggest you look
again at your description which nicely summarises that UTC is based on
decay transitions of Caesium 133 and ordered to a standardised average
(which is what the SI units are all about). Why average? Well, because
decay rates at the atomic level are all probabilities (not certainties)
and so have a pretty wide spread of actual values... hence the infamous
Schroedinger's Cat experiment.
Jul 23 '05 #17
JRS: In article <cr************ *******@news.de mon.co.uk>, dated Tue, 4
Jan 2005 17:27:34, seen in news:comp.lang. javascript, Mark Preston
<us****@nosourc e.co.uk> posted :
Dr John Stockton wrote:
JRS: In article <cr************ *******@news.de mon.co.uk>, dated Mon, 3
Jan 2005 16:31:02, seen in news:comp.lang. javascript, Mark Preston
<us****@nosourc e.co.uk> posted :
UTC, on the other hand, is a derived
probabilisti c decay-rate measurement.


Total rubbish. It has nothing at all to do with decay rates. UTC is
based on the SI second, which is based on a precise transition of Cs-133
(see footnote [+] to my previous article), plus adjustments to make it
agree with one of the GMT-class time scales to within 0.9 seconds.

See my WWW site, and confirm by means of the links it contains; do not
trust amateur sources.

Umm - yes, it is. But as I just pointed out in one sentance exactly the
same thing I don't see your problem.

In case you are not sure why they are the same then I suggest you look
again at your description which nicely summarises that UTC is based on
decay transitions of Caesium 133 and ordered to a standardised average
(which is what the SI units are all about). Why average? Well, because
decay rates at the atomic level are all probabilities (not certainties)
and so have a pretty wide spread of actual values... hence the infamous
Schroedinger 's Cat experiment.


Obviously you have stuck in your mind a total misapprehension about the
physics of a Caesium Clock. The operation is utterly different from the
possibly so-called Atomic Clock used in archaeological carbon dating,
which is based on radioactive decay of the C14 nucleus; it is a matter
of transitions between electronic energy levels, and "decay" is not an
appropriate term.

Don't argue physics with an experienced physicist when you are not one
yourself; and, if you must do so, be careful to choose a topic which is
not so closely adjacent to his own. By adjacent, I don't just mean
similar, but literally along-the-corridor.

For further information on the physics of the Caesium Clock, consult the
NPL, NIST, and BIPM Web sites - it should be on all of them (NIST, at
least, is liable to call it Cesium). It will also be in books in the
larger public libraries.

--
© John Stockton, Surrey, UK. *@merlyn.demon. co.uk / ??*********@phy sics.org ©
Web <URL:http://www.merlyn.demo n.co.uk/> - FAQish topics, acronyms, & links.
Correct <= 4-line sig. separator as above, a line precisely "-- " (SoRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SoRFC1036)
Jul 23 '05 #18

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

Similar topics

15
43016
by: Simon Brooke | last post by:
I'm investigating a bug a customer has reported in our database abstraction layer, and it's making me very unhappy. Brief summary: I have a database abstraction layer which is intended to mediate between webapps and arbitrary database backends using JDBC. I am very unwilling indeed to write special-case code for particular databases. Our code has worked satisfactorily with many databases, including many instances MS SQLServer 2000...
7
2524
by: Andy Davis | last post by:
I have a table of data in Access 2002 which is used as the source table for a mail merge document using Word 2002 on my clients PC. The data is transferred OK but I've noticed that any dates which fall between 1stday/anymonth/any year and 12thday/anymonth/any year are rearranged in the wrong format. For example 4th July 2005 from the database would be displayed as 07/05/2005 in the merged document. In addition blank date fields from the...
3
1542
by: Jeff S | last post by:
Not a showstopper (but annoying nevertheless): On the Start page of VS.NET 2003, the list of projects from which I can choose shows the Modified date of each project listed. The date actually displayed on my list is the date the project was created (not modified). I can open and close the project, save changes, etc, and the date listed does not change. On another computer with VS.NET 2003, the ModifiedDate gets updated to the current...
12
29469
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as follows: function doDateCheckNow(source, args) { var oDate = document.getElementById(source.controltovalidate); // dd/mm/yyyy
9
6372
by: insomniux | last post by:
Hi, I am having a problem with formatting the default value of a date field. It has been discussed earlier in many topics, but still I cannot solve the problem. What's happening: I have various forms which are based on an ODBC-linked tables. In one of the forms, I have a control which shows the date of a date field in my database (storage type=date). The default value for the control is set to '=Date()', the format property is set to...
1
2804
by: mai | last post by:
Hi everyone, i'm trying to exhibit FIFO anomaly(page replacement algorithm),, I searched over 2000 random strings but i couldnt find any anomaly,, am i I doing it right?,, Please help,,,The following is the code,, #include <iostream> #include <string> #include <stdio.h> #include <stdlib.h> #include <ctime // For time()
30
5717
by: fniles | last post by:
On my machine in the office I change the computer setting to English (UK) so the date format is dd/mm/yyyy instead of mm/dd/yyyy for US. This problem happens in either Access or SQL Server. In the database I have a table with Date/time column. The database is located on a machine that is set to dd/mm/yyyy also. When I enter date 7/1/08 (as in January 7, 2008), it stores it in the database as 1/7/08 instead of 7/1/08. Why is it like that...
4
3059
by: OzNet | last post by:
I have some functions to calculate the working days in a given period. This includes a table that is queried to calculate the number of public holidays that don’t occur on a weekend. If I test the function using the intermediate window, it works fine. However, when I pass the dates from the code attached to my form, the results are inaccurate. You will notice my dates are in Australian format. Everything works fine using the Australian...
11
6203
ollyb303
by: ollyb303 | last post by:
Hello, I am using a dynamic crosstab report to track performance statistics for my company and I have hit a problem. I would like the option to track stats daily (for the last 7 complete days), weekly (for the last 6 weeks) and monthly (for the last 6 complete months). Daily and monthly are not causing me a problem - I have used the following code to construct the query: strXT = "TRANSFORM Sum(Query2.STAT) AS SumOfSTAT " & _...
0
9432
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10232
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8891
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7420
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.