Convert HH:MM:SS to seconds in momentjs

后端 未结 3 751
伪装坚强ぢ
伪装坚强ぢ 2021-02-04 02:38

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

3条回答
  •  無奈伤痛
    2021-02-04 03:27

    Try something like this:

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

    returns 43812

提交回复
热议问题