by using youtube api v3, getting duarion in below formation.
pt3h32m50s i want transform 03:32:50 format.
please note: if video not hour long then, pt32m50s. in case, should 00:32:50.
please guide me best possible solution.
i have got below solution works in possible scenarios.
$duration = str_ireplace(array('pt', 'h', 'm', 's'), array('',':',':',''), $youtubearrdata->items[0]->contentdetails->duration); if(substr_count($duration, ':') == 0){ $duration = "00:00:".$duration; } if(substr_count($duration, ':') == 1){ $duration = "00:".$duration; } $video_length = date("h:i:s.u", strtotime($duration)); hope works everybody.
Comments
Post a Comment