我有两个变量,例如:
$from = 13:43:13;
$to = 18:53:13;
Run Code Online (Sandbox Code Playgroud)
我需要在PHP计算之间的时间$from和$to,这样$total就会像:
$total = 5.10 // 5 hours and ten minutes
Run Code Online (Sandbox Code Playgroud)
要么
$total = 0.40 // 0 hours and 40 minutes
Run Code Online (Sandbox Code Playgroud)
我不介意秒,我需要的是小时和分钟.
请帮我 :)
$from = '13:43:13';
$to = '18:53:13';
$total = strtotime($to) - strtotime($from);
$hours = floor($total / 60 / 60);
$minutes = round(($total - ($hours * 60 * 60)) / 60);
echo $hours.'.'.$minutes;
Run Code Online (Sandbox Code Playgroud)