最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Formatting time using moment JS shows incorrect Date - Stack Overflow

programmeradmin2浏览0评论

I have time ing 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?

I have time ing 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?

Share Improve this question edited Sep 8, 2016 at 2:38 user663031 asked Sep 7, 2016 at 23:38 Raghu ChaitanyaRaghu Chaitanya 1511 gold badge2 silver badges9 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

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

发布评论

评论列表(0)

  1. 暂无评论