Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
115
rated 0 times [  120] [ 5]  / answers: 1 / hits: 47993  / 9 Years ago, mon, april 20, 2015, 12:00:00

I have a string with 12 hour formatted time only



var time=12:10:12: PM



I want to convert this string to seconds.



how can i do this in moment.js?


More From » jquery

 Answers
9

Try something like this:



moment('12:10:12: PM', 'HH:mm:ss: A').diff(moment().startOf('day'), 'seconds');


returns 43812


[#66998] Friday, April 17, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
braidenv

Total Points: 80
Total Questions: 104
Total Answers: 91

Location: Peru
Member since Fri, Oct 14, 2022
2 Years ago
;