php秒转换为天 时 分 秒
时间: 2023-12-16 13:54:41 浏览: 121
php代码-秒换算为剩余天小时分秒
以下是将PHP秒转换为天时分秒的示例代码:
```php
function secondsToTime($seconds) {
$days = floor($seconds / (3600 * 24));
$hours = floor(($seconds / 3600) % 24);
$minutes = floor(($seconds / 60) % 60);
$seconds = $seconds % 60;
return array('days' => $days, 'hours' => $hours, 'minutes' => $minutes, 'seconds' => $seconds);
}
// 示例使用
$seconds = 86460; // 1 天 0 小时 1 分钟 0 秒
$time = secondsToTime($seconds);
echo "{$time['days']} 天 {$time['hours']} 小时 {$time['minutes']} 分钟 {$time['seconds']} 秒";
```
阅读全文