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
Comments
Post a Comment