Moment.js-如何从日期和时间字符串构建时刻? [英] Moment.js - how do I build moment from date and time string?

查看:213
本文介绍了Moment.js-如何从日期和时间字符串构建时刻?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我给定了日期字符串MM-DD-YYYY和时间字符串HH:mm AH:m a,我该如何构建 moment 对象?

If I have given date string MM-DD-YYYY and time string HH:mm A or H:m a, how do I build a moment object?

我尝试了moment('MM-DD-YYYY HH:mm A')无效的方法.

推荐答案

尝试使用格式(第二个)参数moment("12-25-1995", "MM-DD-YYYY");

Try using the format (second) parameter moment("12-25-1995", "MM-DD-YYYY");

有关详细信息,请参见 http://momentjs.com/docs/#/parsing/字符串格式/

For details see http://momentjs.com/docs/#/parsing/string-format/

这篇关于Moment.js-如何从日期和时间字符串构建时刻?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆