简体   繁体   English

Moment.js时间格式错误

[英]Moment.js time format error

I have following where 我有以下地方

moment(13:00:00,'ddd, DD MMM YYYY HH:mm:ss ZZ').format('HH:mm');

I'm expecting 13:00, but i keep getting 5:45 which is GMT I guess. 我预计是13:00,但我会一直保持5:45,这是格林尼治标准时间。

Also, 也,

moment(13:00:00,'ddd, DD MMM YYYY HH:mm:ss ZZ').format('HH:mm am');
I should get 1:00am but O'm getting 5:45am.

Solved the issue by doing following 通过执行以下操作解决了该问题

moment(13:00:00,"hh:mm a").format('hh:mm a');

moment(13:00:00,"HH:mm").format('HH:mm');

The input string requires quotes around it. 输入字符串需要用引号引起来。

Also, the format you pass should match the data. 另外,您传递的格式应与数据匹配。

moment("13:00:00","HH:mm:ss").format("HH:mm")

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

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