3

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?

Robeezy
  • 2,424
  • 3
  • 22
  • 28
  • ECMA-262 says the return value is implementation dependent, so it is not documented there. You may find browser vendor specific documentation. – RobG Oct 09 '12 at 00:00

4 Answers4

2

Three 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?

Community
  • 1
  • 1
PherricOxide
  • 15,493
  • 3
  • 28
  • 41
  • This is perfect, thanks! Date.parse() even simplifies things. – Robeezy Oct 08 '12 at 23:31
  • Do not use `Date.parse()`, even though [ES5](http://ecma-international.org/ecma-262/5.1/#sec-15.9.4.2) defines an [ISO8601–like format](http://ecma-international.org/ecma-262/5.1/#sec-15.9.1.15), the OP isn't in that format and it's not consistent in all browsers. **Manually parse date strings**. – RobG Oct 09 '12 at 00:01
  • 1
    Bah, only in web frontend programming does one have to reinvent the wheel instead of using existing API functions... – PherricOxide Oct 09 '12 at 00:14
1

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

elclanrs
  • 92,861
  • 21
  • 134
  • 171
1

It's not hard to find:

W3Schools: http://www.w3schools.com/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.

A. Matías Quezada
  • 1,886
  • 17
  • 34
1

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.

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143