划分 PHP 时间 (h:i)
divide PHP time (h:i)
我有一个员工时间表,其中持续时间除以员工工作的天数。
例如 25:00 超过 3 天 = 25:00/3=08:20
我试过上面的简单除法查询,但是没有显示结果。是否可以分割 h:m 字符串?
最好的方法是转换为秒并使用日期来显示它。
$time ="25:00";
$days = 3;
list($hours, $minutes) = explode(":", $time);
$minutes += $hours*60;
$seconds = $minutes*60;
date_default_timezone_set ("UTC");
echo "new time: " . date("h:i", $seconds/$days);
查看结果here
我有一个员工时间表,其中持续时间除以员工工作的天数。
例如 25:00 超过 3 天 = 25:00/3=08:20
我试过上面的简单除法查询,但是没有显示结果。是否可以分割 h:m 字符串?
最好的方法是转换为秒并使用日期来显示它。
$time ="25:00";
$days = 3;
list($hours, $minutes) = explode(":", $time);
$minutes += $hours*60;
$seconds = $minutes*60;
date_default_timezone_set ("UTC");
echo "new time: " . date("h:i", $seconds/$days);
查看结果here