题
如何使用PHP转换时间?
原始格式就像 00:02:34 min
.
我需要得到一个回声 154
. 。谢谢。
解决方案
尝试这个:
<?php
date_default_timezone_set('GMT');
$time = '00:00:34';
list ($days, $hours, $minutes) = split(":", $time, 3);
$timestamp = mktime ($hours+1, $minutes, 0, $days+1, 1, 1970, FALSE);
$minutes = $timestamp / 60;
print $minutes;
print "\n";`
(编辑: date_default_timezone_set
添加)
其他提示
$myTime="00:02:34 min";
$bodytag = str_replace(" min", "", $myTime);
$myTime=explode(":",$myTime);
function timeToSeconds($hours,$minutes,$seconds){
return $seconds+($minutes*60)+($hours*3600);
}
不隶属于 StackOverflow