2

I'm trying to both parse and format a date with the format given to me by my server guys as

yyyy-MM-dd,HH:mm:ss.sssZ 2014-05-09,09:00:00.000-0400 

Using moment.js, I can parse a provided date via

moment(date, "YYYY-MM-DD,HH:mm:ss.sssZ") 

This seems to work okay, however if I were to add .format("YYYY-MM-DD,HH:mm:ss.sssZ") I get:

2014-04-30,09:00:00.000-04:00 

For the most part this is okay, but notice the colon in the timezone spot. It should be -0400, not -04:00. I can easily strip off the colon, but before I resort to that, is there any other format string I should be using for parsing and formatting the dates?

I've also tried including moment-timezone.js, but this doesn't make any difference.

1 Answer 1

13

The moment.js documentation says use ZZ instead of Z in your format string.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.