时间:2021-07-01 10:21:17 帮助过:7人阅读
$input = 1234.5678;
strtok((string)$input,'.');
$s = strtok((string)$input,'.') * 60 + strtok('.');
echo $s.'秒';
$t = array('3H45.26','1H5.10','30.59');
echo sumT($t); // 5H21.35
function sumT($t){
$sum = 0;
if($t){
foreach($t as $v){
$sum += getSecond($v);
}
}
return tostr($sum);
}
function getSecond($str){
if(strstr($str,'H')==''){
$str = '0H'.$str;
}
$str = str_replace('H','.',$str);
list($h, $m, $s) = explode('.', $str);
return $h*3600+$m*60+$s;
}
function tostr($t){
$h = (int)($t/3600);
$m = (int)($t%3600/60);
$s = $t%3600%60;
$h = $h>0? $h.'H' : '';
return $h.$m.'.'.$s;
}
echo strtotime('034526') - strtotime(date('Y-m-d')),13526