469,304 Members | 2,192 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,304 developers. It's quick & easy.

Date() - year missing since clocks changed

I have a page that uses the javascript Date() function to retrieve a date
from the client computer.
The date is then inserted into a note that is saved on a database. The date
is in the format
Thursay Oct 30 2003 10.47am

When I access the page using my computer everything works fine.
A colleague in the UK also uses the page and it was fine up until the clocks
changed last weekend. Now notes that he saves have the date in the format
Thursday Oct 30 10.47am i.e. the year is missing.

Presumably something has happened to the date information on his computer so
that Date() is not getting the year any longer. Can anyone suggest how I
might sort this out?

Thanks
Orson
Jul 20 '05 #1
6 1650
"Orson" <bi*****@yahoo.com> writes:
Presumably something has happened to the date information on his computer so
that Date() is not getting the year any longer.
Highly unlikely. The Date object is ususally highly resilient about changes.
User code is not.
Can anyone suggest how I might sort this out?


Not without showing us the code that fails.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:ek**********@hotpop.com...
"Orson" <bi*****@yahoo.com> writes:
Presumably something has happened to the date information on his computer so that Date() is not getting the year any longer.
Highly unlikely. The Date object is ususally highly resilient about

changes. User code is not.


You are correct. Thanks for getting me to think straight. Next week when I
can check it, I am sure I will find the answer lies in the manner I am
chopping up the Date string which will have changed with the switch from
Summer Time.
Jul 20 '05 #3
JRS: In article <bn**********@lust.ihug.co.nz>, seen in
news:comp.lang.javascript, Orson <bi*****@yahoo.com> posted at Fri, 31
Oct 2003 22:59:25 :-

Presumably something has happened to the date information on his computer so
that Date() is not getting the year any longer. Can anyone suggest how I
might sort this out?


Probably you mean new Date() above. The value is a date variable
is stored as milliseconds from 1970-01-01 00:00:00 GMT, and there is no
prospect of the year going absent.

It is conceivable that the year corresponding to the date currently
stored is cached within the object, for efficiency; but even in that
case I would not expect blank or spaces to be returned.

Where the browser is suspected, a questioner should report details of
the system. But it is probable that the code is wrong; it cannot be
diagnosed in more detail without seeing it. Or the database is in
error; arrange to display exactly what is being sent to it.
As you are in NZ, could you check Web <URL:http://www.merlyn.demon.co.uk
/js-date5.htm#Demo>, yellow form, for correctness with NZ selected where
UK initially appears? Select NZ, then Run.

--
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 #4
Lee
Orson said:


"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:ek**********@hotpop.com...
"Orson" <bi*****@yahoo.com> writes:
> Presumably something has happened to the date information on hiscomputer so > that Date() is not getting the year any longer.


Highly unlikely. The Date object is ususally highly resilient about

changes.
User code is not.


You are correct. Thanks for getting me to think straight. Next week when I
can check it, I am sure I will find the answer lies in the manner I am
chopping up the Date string which will have changed with the switch from
Summer Time.


That's a good reason not to get information by chopping up
the Date string. The Date object has methods that return
the month, date, year, day of week, etc.

Jul 20 '05 #5
JRS: In article <bn**********@lust.ihug.co.nz>, seen in
news:comp.lang.javascript, Orson <bi*****@yahoo.com> posted at Sat, 1
Nov 2003 10:49:38 :-

"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:ek**********@hotpop.com...
"Orson" <bi*****@yahoo.com> writes:
> Presumably something has happened to the date information on hiscomputer so > that Date() is not getting the year any longer.


Highly unlikely. The Date object is ususally highly resilient about

changes.
User code is not.


You are correct. Thanks for getting me to think straight. Next week when I
can check it, I am sure I will find the answer lies in the manner I am
chopping up the Date string which will have changed with the switch from
Summer Time.


For me,
new Date(2003, 05) Sun Jun 1 00:00:00 UTC+0100 2003
new Date(2003, 11) Mon Dec 1 00:00:00 UTC 2003
**NEVER** lightly disassemble a string whose format is not rigorously
defined either by yourself or in a document which you have reason to
believe is heeded. Consider whether your browser supplier is likely to
heed documents.

Not only may there be an overlooked variation such as above, but there
may be a variation with browser (etc.) version, or with localisation.

Use the string output functions at most for showing to a human who can
be expected to recognise what it means.

Avoid the string input functions, except that D = new Date("2003/11/01")
seems safe, with 4-digit year, YMD order, and / separator (anyone find
otherwise?), and strings with 4-digit years and month names seem safe if
the spelling can be trusted worldwide.


I've noticed that (in my MSIE4) J = Date.UTC(Year) accepts years
outside the Date Object range - it gives a big number for year 1E297,
and Infinity for 1E298. For large N, Date.UTC(N)/N is, as expected,
close to 31556952000.

--
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 #6

"Dr John Stockton" <sp**@merlyn.demon.co.uk> wrote in message
news:wm**************@merlyn.demon.co.uk...
JRS: In article <bn**********@lust.ihug.co.nz>, seen in
news:comp.lang.javascript, Orson <bi*****@yahoo.com> posted at Fri, 31
Oct 2003 22:59:25 :-

Presumably something has happened to the date information on his computer sothat Date() is not getting the year any longer. Can anyone suggest how I
might sort this out?


Probably you mean new Date() above. The value is a date variable
is stored as milliseconds from 1970-01-01 00:00:00 GMT, and there is no
prospect of the year going absent.

It is conceivable that the year corresponding to the date currently
stored is cached within the object, for efficiency; but even in that
case I would not expect blank or spaces to be returned.

Where the browser is suspected, a questioner should report details of
the system. But it is probable that the code is wrong; it cannot bet
diagnosed in more detail without seeing it. Or the database is in
error; arrange to display exactly what is being sent to it.
As you are in NZ, could you check Web <URL:http://www.merlyn.demon.co.uk
/js-date5.htm#Demo>, yellow form, for correctness with NZ selected where
UK initially appears? Select NZ, then Run.


It was in the code.
I am embarrassed to say that I had chopped up the string without regard for
the consequences. I am now using the proper date object methods and the
problem is resolved.

With regard to your demo page, everything appears in order when I set the
form to NZ and click run.

Thank you all for your help.

Orson
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Astra | last post: by
6 posts views Thread by MickG | last post: by
23 posts views Thread by Ash | last post: by
2 posts views Thread by Riegn Man | last post: by
19 posts views Thread by Ricardo Perez Lopez | last post: by
26 posts views Thread by jshanman | last post: by
13 posts views Thread by priyasmita_guha | last post: by
4 posts views Thread by Dr J R Stockton | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.