简体   繁体   English

使用 moment.js 格式化日期

[英]Formatting date with moment.js

I have a date like this 2021-10-20T07:03:02-04:00 and from this date I need to make date like this: Wednesday 7:03am我有一个这样的日期2021-10-20T07:03:02-04:00从这个日期开始我需要这样约会: Wednesday 7:03am

My try:我的尝试:

moment(date).format('dddd h:mma');

But I get Wednesday 14:03am .但我得到了Wednesday 14:03am Do you have any idea how to fix it?你知道如何解决它吗?

像使用它一样

moment(date).format('DDDD HH:MM a');

As mentioned in momentjs docs you can do it like this正如momentjs docs中提到的,你可以这样做

moment(someday).format('dddd HH:MM a');

moments docs >>时刻文档 >>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM