简体   繁体   English

Moment.js没有为GMT日期和时间提供正确的格式

[英]Moment.js not giving correct format for GMT date and time

I am trying to convert local time into GMT time in 'YYYY-DD-MM HH:MM' format. 我正在尝试将本地时间转换为GMT时间,格式为“ YYYY-DD-MM HH:MM”。 I have tried: 我努力了:

moment.utc(new Date(),'YYYY-DD-MM HH:MM').format('YYYY-DD-MM HH:MM') 

and also tried 并尝试了

 moment().utc().format('YYYY-DD-MM HH:MM')

but for PST time 2017-12-10 17:45 the output is coming 2017-13-10 00:10. 但对于PST时间2017-12-10 17:45,输出将在2017-13-10 00:10到来。 The minutes are not coming properly. 分钟未到。 Not sure what am I doing wrong. 不知道我在做什么错。

This is because M is short for month, and m is short for minute. 这是因为M表示月份,而m表示分钟。 Read the documentation more thoroughly. 更彻底地阅读文档

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

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