Hawaii timezone date makes invalid JavaScript date

For some reason, when I pass a date with the time zone of Hawaii to JavaScript Date() , I get an "invalid date", but in any other time zone I do not. 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

+6
source share
1 answer

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 a numeric value relative to UTC or GMT. For HAST, this will be UTC-1000 (10 hours before UTC):

 var HAST = 'Wed, 31 Jul 2013 07:21:16 UTC-1000'; 

Fiddle

+7
source

Source: https://habr.com/ru/post/950744/