$t=1637544;
$d=Sec2Time($t);
$d is 0 years, 18 days, 22 hours, 52 minutes and 24 seconds
//Convert seconds to time (year, day, hour , minutes, seconds)
<span>function</span> Sec2Time(<span>$time</span><span>){ </span><span>if</span>(<span>is_numeric</span>(<span>$time</span><span>)){ </span><span>$value</span> = <span>array</span><span>( </span>"years" => 0, "days" => 0, "hours" => 0, "minutes" => 0, "seconds" => 0,<span> ); </span><span>if</span>(<span>$time</span> >= 31556926<span>){ </span><span>$value</span>["years"] = <span>floor</span>(<span>$time</span>/31556926<span>); </span><span>$time</span> = (<span>$time</span>%31556926<span>); } </span><span>if</span>(<span>$time</span> >= 86400<span>){ </span><span>$value</span>["days"] = <span>floor</span>(<span>$time</span>/86400<span>); </span><span>$time</span> = (<span>$time</span>%86400<span>); } </span><span>if</span>(<span>$time</span> >= 3600<span>){ </span><span>$value</span>["hours"] = <span>floor</span>(<span>$time</span>/3600<span>); </span><span>$time</span> = (<span>$time</span>%3600<span>); } </span><span>if</span>(<span>$time</span> >= 60<span>){ </span><span>$value</span>["minutes"] = <span>floor</span>(<span>$time</span>/60<span>); </span><span>$time</span> = (<span>$time</span>%60<span>); } </span><span>$value</span>["seconds"] = <span>floor</span>(<span>$time</span><span>); </span><span>//</span><span>return (array) $value;</span><span>$t</span>=<span>$value</span>["years"] ."年". <span>$value</span>["days"] ."天"." ". <span>$value</span>["hours"] ."小时". <span>$value</span>["minutes"] ."分".<span>$value</span>["seconds"]."秒"<span>; </span><span>Return</span><span>$t</span><span>; }</span><span>else</span><span>{ </span><span>return</span> (bool) <span>FALSE</span><span>; } }</span>
The above introduces PHP to convert seconds into time (years, days, hours, minutes, seconds), including the content. I hope it will be helpful to friends who are interested in PHP tutorials.