Converting Youtube Data API V3 video duration format to seconds in JavaScript/Node.js

后端 未结 15 2028
北海茫月
北海茫月 2020-12-05 07:09

I\'m trying to convert ISO 8601 string to seconds in JS/Node. The best I could come up with was:

function convert_time(duration) {
    var a = duration.match         


        
15条回答
  •  攒了一身酷
    2020-12-05 07:31

    If you're using moment.js you can simply call...

    moment.duration('PT15M33S').asMilliseconds();
    

    = 933000 ms

提交回复
热议问题