I have a date/time displayed using "new date()".
It currently displays
"Thu May 31 2012 13:04:29 GMT-0500 (CDT)".
I need this:
"Thu May 31 13:04:29 CDT 2012".
How do I format it?
You can use a regular expression to extract the timezone from the standard date string.
var d = new Date();
var customFormat = d.toString().slice(0,7) + ' ' + //Day and Month
d.getDate() + ' ' + //Day number
d.toTimeString().slice(0,8) + ' ' + //HH:MM:SS
/\(.*\)/g.exec(d.toString())[0].slice(1,-1) //TimeZone
+ ' ' + d.getFullYear(); //Year
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With