For some reason, when I pass a date with a Hawaii time zone to JavaScript's Date()
I get "invalid date", but any other time zone I don't. Is there a workaround for this?
var HAST = 'Wed, 31 Jul 2013 07:21:16 HAST';
var hawaiiTime = new Date(HAST);
console.log("Hawaii time: "+hawaiiTime);
// Hawaii time: Invalid Date
var PST = 'Wed, 31 Jul 2013 07:21:16 PST';
var pacificTime = new Date(PST);
console.log("Pacific time: "+pacificTime);
// Pacific time: Wed Jul 31 2013 09:21:16 GMT-0600 (MDT)
jsFiddle
RFC 2822 only supports North American UT Offsets (See Page 32).
"EST" / "EDT" / ; Eastern: - 5/ - 4
"CST" / "CDT" / ; Central: - 6/ - 5
"MST" / "MDT" / ; Mountain: - 7/ - 6
"PST" / "PDT" / ; Pacific: - 8/ - 7
For everything else, you should use the numeric value relative to UTC or GMT. For HAST, this would be UTC-1000
(10 Hours before UTC):
var HAST = 'Wed, 31 Jul 2013 07:21:16 UTC-1000';
Fiddle
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