php - get youtube video duration in specific format -


i'm using youtube version 3 api video data, got duration of video in iso 8601 format, tried convert hh:mm:ii using following code

<?php $duration = 'pt3m42s';  $time = strtotime($duration);  $durationconverted = time('hh : mm : ii', $duration); echo $durationconverted;  ?> 

but result = 1431647650 , want pt3m42s converted 00:03:42 or 03:42

$duration = new dateinterval('pt3m42s'); echo $duration->format('%h:%i:%s'); 

00:03:42

http://php.net/manual/en/class.dateinterval.php


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -