0

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 Answers1

0

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'];
}
vikujangid
  • 728
  • 3
  • 8
  • 19
  • why are the results so no additional hour? sample result becomes 22:02:00, I want the result 00:02:00 – CoffeToBrought Apr 05 '16 at 06:47
  • because playtime_string returns minutes and seconds format (m:s) and then you are converting it to strtotime, which is considering it to (H:i / H:m) and adding seconds itself after the H:m. So if we already passed hour value (h) to strtotime than it will not consider it to H:m. Now it will know as H:i:s – vikujangid Apr 05 '16 at 08:48