how to change time from getID3

322 Views Asked by At

i have the problem about result strtotime in php from getID3, this result is 02:00:00 but i want to result is 00:02:00, how can change it ? please help and thanks

$durasi = getDuration($direktori);
$endtime = date('H:i:s', strtotime($durasi));

function getDuration($file){
include_once("getID3/getid3/getid3.php");
$getID3 = new getID3;
$file = $getID3->analyze($file);
return $file['playtime_string'];
}
1

There are 1 best solutions below

2
vikujangid On

The playtime_string returns minutes and seconds (m:s). So you have to add hours to it for make strtotime string. Use gmdate() function instead of date() to make h:i:s format.

Hope this will be helpful

$durasi = getDuration($direktori);
$endtime = gmdate('H:i:s', strtotime('00:'.$durasi)); /// make these changes

function getDuration($file){
  include_once("getID3/getid3/getid3.php");
  $getID3 = new getID3;
  $file = $getID3->analyze($file);
  return $file['playtime_string'];
}