The return value for (new Date()).toDateString()
is "Mon Oct 08 2012"
. However I can't find ANY documentation anywhere for what the abbreviations for the rest of the days of the week and months are. Are they all just 3 character abbreviations? I'm trying to write a regex.
+1million points for someone who can find the documentation, or even the source code?
The return value for (new Date()).toDateString()
is "Mon Oct 08 2012"
. However I can't find ANY documentation anywhere for what the abbreviations for the rest of the days of the week and months are. Are they all just 3 character abbreviations? I'm trying to write a regex.
+1million points for someone who can find the documentation, or even the source code?
Share Improve this question asked Oct 8, 2012 at 22:52 RobeezyRobeezy 2,4643 gold badges23 silver badges28 bronze badges 1- ECMA-262 says the return value is implementation dependent, so it is not documented there. You may find browser vendor specific documentation. – RobG Commented Oct 9, 2012 at 0:00
4 Answers
Reset to default 2Three letter abbreviations with the first letter upper case.
- Months: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
- Days: Sun, Mon, Tue, Wed, Thu, Fri, Sat
However, you may want to look into Date.Parse() instead of using a regular expression to parse the date string, depending on what you're doing anyway.
EDIT: Beware that that Date.Parse() is fairly browser dependent. Check out Why does Date.parse give incorrect results?
It's just the standard English language abbreviation for days and months. Just the first 3 letters and the first one capitalized.
From the MDN:
Date instances refer to a specific point in time. Calling toString will return the date formatted in a human readable form in American English
It's not hard to find:
W3Schools: http://www.w3schools./jsref/jsref_todatestring.asp
Mozilla Developer Network: link
Microsoft Developer Network: link
As you can see, all of them converge, its the week day, the month name, both with 3 characters, day of month and full year.
The specification does not define the output of the string:
The contents of the String are implementation-dependent, but are intended to represent the "date" portion of the Date in the current time zone in a convenient, human-readable form.
This might change in the future, but for now, each browser/environment can produce a different output.