After reading this question – which also provides links to documentation , I still have a question about the documentation.
MDN : Date.parse
A string representing an RFC2822 or ISO 8601 date.
Ok , RFC2282 :
date-time = [ day-of-week "," ] date FWS time [CFWS]
day-of-week = ([FWS] day-name) / obs-day-of-week
day-name = "Mon" / "Tue" / "Wed" / "Thu" /
"Fri" / "Sat" / "Sun"
date = day month year
year = 4*DIGIT / obs-year
month = (FWS month-name FWS) / obs-month
month-name = "Jan" / "Feb" / "Mar" / "Apr" /
"May" / "Jun" / "Jul" / "Aug" /
"Sep" / "Oct" / "Nov" / "Dec"
day = ([FWS] 1*2DIGIT) / obs-day
Now – ISO8601
Year:
YYYY (eg 1997)
Year and month:
YYYY-MM (eg 1997-07)
Complete date:
YYYY-MM-DD (eg 1997-07-16)
Ok.
Questions :
-
MDN provided a pattern sample (which is working)
"Dec 25, 1995"which is not found in 2282 nor in ISO .
How come this sample works ? the order must beday month year( according to 2282) . -
the separators in the standards are
[space]( in 2282) and[-]in ISO.So why this sample works ( cross browser) ?
Date.parse("2011/11/23")
For
Date.parse, have a look at the EcmaScript specification, section 15.9.4.2:So, MDN’s Mozilla-specific documentation is quite near that. The official “EcmaScript Date Time String Format” is a subset of ISO 8601, otherwise Gecko browsers try to interpret it as RFC 2822 or even something else (this might include
"Dec 25, 1995"). I strongly suspect that"2011/11/23"really works cross-browser, although it might be true for recent versions.