将天、小时、分钟和秒转换为整数

Convert Days, Hours, Minutes and Seconds to an integer

我可以将 int 转换为天、小时、分钟和秒,但是将其反转并转换回秒的计算是什么?

这是我第一次转换的结果:

<?php
$seconds = 12345;
$days = floor ($seconds / 60 / 60 / 24);
$hours = floor ($seconds / 60 / 60) % 24;
$minutes = floor ($seconds / 60) % 60;
$seconds = $seconds % 60;
?>
$total = ($days * 24 * 60 * 60) + ($hours * 60 * 60) + ($minutes * 60) + $seconds;

试试这个

$total = ($days * 24 * 60 * 60) + ($hours * 60 * 60) + ($minutes * 60) + $seconds;