I have a string like
"9:00:00 AM"
How do i convert it into a javascript datetime object?
Currently I am using bootstrap timepicker but the control passes the value back as string
I'm using moment.js for every date-time related parsing and formatting (also for Angular projects). Works like a charm. Give it a try. Should work for your case:
moment("9:00:00 AM", "HH:mm:SS A").toDate();
See
var d = moment("9:00:00 AM", "HH:mm:SS A").toDate();
d instanceof Date // -> true
new Date('2015-1-15 9:00:00 AM')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.