I am parsing some data on a website using PHP and it gives me the amount of time in this format:
P16DT1H58M47S
But they don’t always have the number of days, like so:
PT8H10M3S
And sometimes no hours:
PT33M57S
What I need to find is a way to convert that to a total number of seconds. I do NOT need to put that into a date object, but I would like to find a fairly quick way to do this as I have a lot of data to go through.
http://www.php.net/manual/en/dateinterval.construct.php