Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible return values for (new Date()).toDateString() in JavaScript?

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?

like image 317
Robeezy Avatar asked Apr 19 '26 17:04

Robeezy


1 Answers

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?

like image 150
PherricOxide Avatar answered Apr 22 '26 06:04

PherricOxide



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!