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

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

问题描述

如果我已给出日期字符串 MM-DD-YYYY 且时间字符串 HH:mm A H:ma ,如何构建一个时刻对象?我尝试了时刻('MM-DD-YYYY HH:mm A')哪个不起作用。

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? I tried moment('MM-DD-YYYY HH:mm A') which did not work.

推荐答案

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

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

详见 http:/ /momentjs.com/docs/#/parsing/string-format/

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

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