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.
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
To create a moment
object
of your desired time, do the following:In this case '05-17-2018 23:40 AM' is the desired time.
Try using the format (second) parameter
moment("12-25-1995", "MM-DD-YYYY");
For details see http://momentjs.com/docs/#/parsing/string-format/