473,763 Members | 2,930 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 #1
17 2513
Lee
clintonG said:

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.


Are you sure it shows the time as 19:54:18?
At that time CST it *is* the next day in GMT.

Jul 23 '05 #2
Thank you for your attention. We can scratch that time for now noting the
discrepancy may be because I copied and pasted to make things easier to read
but read or run the following please...

//Example A
//Returns: Sun Dec 26 2004 10:49:25 GMT-0600 (Central Standard Time)
var expDate = new Date( );
document.write( "expDate: " + expDate + "<br />");
//Example B
//Returns: Sun, 26 Dec 2004 16:49:25 GMT
var today = new Date( );
var myDateString = today.toGMTStri ng( );
document.write( "myDateStri ng: " + myDateString);

I understand what is going on now. Example A uses the Date method that
returns time as CST which is GMT-0600 hours (6 hours less than GMT) so
sitting in front of a computer in a region that uses CST (me) and running
Example B at a time of day less than 6 hours from midnight in Greenwich will
indicate the date as the 'next day' when the the Date( ) method is overriden
by the toGMTString( ) method.

<%= Clinton Gallagher


"Lee" <RE************ **@cox.net> wrote in message
news:cq******** *@drn.newsguy.c om...
clintonG said:

When the following code is run on Sat Dec 25 2004 19:54:18 GMT-0600 (CentralStandard 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.


Are you sure it shows the time as 19:54:18?
At that time CST it *is* the next day in GMT.

Jul 23 '05 #3
On Sun, 26 Dec 2004 11:03:47 -0600, clintonG
<cs*********@RE MOVETHISTEXTmet romilwaukee.com > wrote:

[snip]
var today = new Date( );
var myDateString = today.toGMTStri ng( );


Just so you know, the toGMTString method is deprecated in favour of the
toUTCString method. The effect if the same, though.

[snip]

Mike
Please don't top-post.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #4
Thank you. I'll try that out right now...

<%= Clinton Gallagher

"Michael Winter" <M.******@bluey onder.co.invali d> wrote in message
news:opsjmlj2uo x13kvk@atlantis ...
On Sun, 26 Dec 2004 11:03:47 -0600, clintonG
<cs*********@RE MOVETHISTEXTmet romilwaukee.com > wrote:

[snip]
var today = new Date( );
var myDateString = today.toGMTStri ng( );


Just so you know, the toGMTString method is deprecated in favour of the
toUTCString method. The effect if the same, though.

[snip]

Mike
Please don't top-post.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.

Jul 23 '05 #5
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.

var today = new Date();
var UTCDateTime = today.toUTCStri ng();
document.write( "<b>UTCDateTime : </b>" + UTCDateTime);

<%= Clinton Gallagher
"Michael Winter" <M.******@bluey onder.co.invali d> wrote in message
news:opsjmlj2uo x13kvk@atlantis ...
On Sun, 26 Dec 2004 11:03:47 -0600, clintonG
<cs*********@RE MOVETHISTEXTmet romilwaukee.com > wrote:

[snip]
var today = new Date( );
var myDateString = today.toGMTStri ng( );


Just so you know, the toGMTString method is deprecated in favour of the
toUTCString method. The effect if the same, though.

[snip]

Mike
Please don't top-post.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.

Jul 23 '05 #6
On Sun, 26 Dec 2004 20:20:47 GMT, clintonG
<cs*********@RE MOVETHISTEXTmet romilwaukee.com > wrote:

Please don't top-post.
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 the method:

"This function returns a string value. The contents of the string
are implementation-dependent, but are intended to represent the
Date in a convenient, human-readable form in UTC."

-- Section 15.9.5.42, ECMA-262

If you need a specific format, it's best to do it yourself.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #7
Lee
clintonG said:

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.


Welcome to the newsgroup.

Referring to popular browsers as "Firefraud" or "Netscrape" , etc is not really a
good way to ensure your popularity or that you will receive the best possible
answers to your questions. You're sure to piss off a few and make a few more
write you off as a childish twit.

Pointing out that IE "makes the trains run on time" isn't going to change many
opinions, anyway.

Jul 23 '05 #8
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.
Jul 23 '05 #9
JRS: In article <R%************ ********@twiste r.rdc-kc.rr.com>, dated
Sun, 26 Dec 2004 04:22:09, seen in news:comp.lang. javascript, clintonG
<cs*********@RE MOVETHISTEXTmet romilwaukee.com > posted :
When the following code is run on Sat Dec 25 2004 19:54:18 GMT-0600 (Central
Standard Time)
Please note that this is an international newsgroup. Terms such as
"Central Standard Time" are therefore not generally helpful, since we do
not know of what it might be the centre. Russia? Australia?
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.


There is something wrong with your system or its operator.
Note : this response to your article is formatted in accordance with
standard usenet recommendations endorsed by the Wednesday edition of the
FAQ (which you should have read) of this newsgroup.

Note : Americans, and the software that they originate, traditionally
have a very poor understanding of date and time, except as it applies in
CONUS, maybe AK & HI, and just possibly CA (the region which prevents AK
from being an island). It is not only non-Americans that need to allow
for that.

--
© 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 #10

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

Similar topics

15
43015
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
2523
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
1541
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
29468
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
2802
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
5716
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
3057
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
9383
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
9992
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...
1
9935
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8821
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
7364
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
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5268
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...
1
3916
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
3519
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.