Abbreviations MomentJs and Timezone

I'm having problems with momentjs library

line

moment("Mon Oct 14 01:00:00 GMT 2013")  parses correctly 

but the line

moment("Mon Oct 14 01:00:00 BST 2013")  throws an invalid date

I tried to create a format string, but the zz format, which I think I need, is deprecated, there is a way to completely skip the BST / GMT bit, since I am only interested in the date

Thanks in advance.

+4
source share
1 answer

Time zone abbreviations are not unique, so they cannot be analyzed. You can ignore it by putting any non-format character as a placeholder:

moment("Mon Oct 14 01:00:00 BST 2013","ddd MMM DD HH:mm:ss ? YYYY")

But you should know that, ignoring it, you will accept the local time zone of the computer on which the code is running. Set the computer to a different time zone and call .format()and you will see what I mean.

, - . , , , - ? , , . , UTC . , - , UTC , .

moment.utc("Mon Oct 14 01:00:00 BST 2013","ddd MMM DD HH:mm:ss ? YYYY")
+3

All Articles