Raghu Chaitanya
Raghu Chaitanya

Reputation: 151

Formatting time using moment JS shows incorrect Date

I have time coming from server in certain format for example time is (1473286826319). Using MomentJS library

moment(1473286826319).format()
// output 2016-09-07T16:20:26-06:00 i.e sep 7 2016 

However when I use custom formating style as below

moment(1473286826319).format('dddd, MMMM d, YYYY, h:mm A');
// output Wednesday, September 3, 2016, 4:20 PM

I have the date going back from Sept 7 to Sept 3 and rest of the data is accurate. Is there something I am doing wrong?

Upvotes: 3

Views: 2038

Answers (1)

Lux
Lux

Reputation: 18240

You are using a small d which is the Day of Week. If you want the Day of Month use a D or a DD for leading zeros.

Checkout the documentation

Upvotes: 9

Related Questions