I'm currently grabbing the length of a mp3 file from ffmpeg which results in a time such as 00:03:50.76 I'm needing to turn this into just total seconds without the milliseconds.
So the above would be 230 seconds. Would regex suffice for this?
I'm currently grabbing the length of a mp3 file from ffmpeg which results in a time such as 00:03:50.76 I'm needing to turn this into just total seconds without the milliseconds.
So the above would be 230 seconds. Would regex suffice for this?
Use this:
$res = "00:04:12.44";
$ex = explode(".", $res);
$res = $ex[0];
$secs = strtotime("01.01.1970 " . $res);
Or - see the comment of Sven:
$res = "00:03:50.76";
$ex = explode(".", $res);
$res = $ex[0];
$ex = explode(":", $res);
$secs = $ex[0] * 3600 + $ex[1] * 60 + $ex[2]; // 230 secs