I have an iso-8601 duration which is as follows:
PT15M51S
I want to convert the duration into seconds so that I can store it in the db and order by duration etc.
Here is what I tried so far:
var moment = require('moment');
var duration = 'PT15M51S';
var x = moment(duration, moment.ISO_8601);
console.log(x.seconds());
Which results in NaN
.