Reputation: 1101
I would like to know is it possible to convert string time
to moment in javascript.
I am using moment.js
var str="11:00" // convert this to moment()
I tried
var result = moment(str); //not working
Upvotes: 0
Views: 1563
Reputation: 819
you can do it as follows
moment(str, 'h:mm a')
for more information please refer https://momentjs.com/docs/#/parsing/
Upvotes: 0
Reputation: 38114
You can use format
method:
moment('11:00','h:mm a').format('h:mm a');
Upvotes: 1