In comp.lang.javascript message <k3u1v3$kq2$
1...@dont-email.me>, Wed, 26
Sep 2012 07:57:08, Jukka K. Korpela <
jkor...@cs.tut.fi> posted:
>
>Before even considering that, consider how you are constructing the
>Date value. When you invoke new Date(...) with an argument like
>"9/25/2012", the effect is implementation-dependent. The string
>argument will be parsed with Date.parse(), about which clause 15.9.4.2
>of the ECMAScript standard says:
>
>"The function first attempts to parse the format of the String
>according to the rules called out in Date Time String Format
>(15.9.1.15). If the String does not conform to that format the function
>may fall back to any implementation-specific heuristics or
>implementation-specific date formats."
So writes a theoretician from the back of beyond - a nice place
(mosquitoes apart) certainly; but isolated.
The Standard permits, but does not require, entirely implementation-
dependent parsing, after trying 15.9.1.15.
The real world is aware that all or almost all browsers are either
written in America or are written with the US market, and MS IE
compatibility, firmly in mind.
Therefore, not only will the weird US date format be supported, but it
will be AT LEAST as reliable as any other date format.
The best format to use, however, is "2012/09/25". It has all of the
advantages of ISO 8601 except for compliance, and I don't recall it
failing with new Date() in any browser. But, if using other code,
beware as treating "09" as Octal Zero.
The OP needs to consider whether the whole of that day should be
matched, and whether the offset from GMT might vary.
If only the "calendar" date is wanted, then it is best to use UTC
methods throughout.
NEVER use new Date() except for the measurement of intervals of time.
Use instead new Date(0), which gives consistent results and ought to be
faster.
Query : What do the "Safari" parts of
<
http://www.merlyn.demon.co.uk/js-datex.htm> report when using Safari 6
or higher?
--
(c) John Stockton, nr London, UK. ?@
merlyn.demon.co.uk Turnpike v6.05.
Website <
http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc. : <
http://www.merlyn.demon.co.uk/programs/> - see in 00index.htm
Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.