Time format conversion with PHP
4 answers
<?php
function getBetween($content, $start, $end) {
$r = explode($start, $content);
if (isset($r[1])) {
$r = explode($end, $r[1]);
return $r[0];
}
return '';
}
$dur = "1H2M3S";
$hr = strtok($dur, "H");
$min = getBetween($dur, "H", "M");
$sec = getBetween($dur, "M", "S");
Do what you want to do with $ hr, $ min and $ sec.
0
source to share