Get the App
SLTechnology News&Howtos  ›  Development  › 

How to change seconds to time in php

Shulou Source: shulou.com Published: 2022-06-03 10:05:40 09月27日 Update

This article mainly shows you "how to turn seconds into time in php". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to turn seconds to time in php".

Php will change the number of seconds to time: 1, create a PHP sample file; 2, through the "function Sec2Time ($time) {.}" method to convert the number of seconds into time.

This article operating environment: Windows7 system, PHP7.1 version, DELL G3 computer

How does php turn the seconds into time?

Php converts seconds to time (year, day, hour, minute, second)

$twee1637544 / sec2Time ($t)

$d is 18 days, 22 hours, 52 minutes, 24 seconds

Convert the number of seconds to time (year, day, hour, minute, second)

Function Sec2Time ($time) {if (is_numeric ($time)) {$value = array ("years" = > 0, "days" = > 0, "hours" = > 0, "minutes" = > 0, "seconds" = > 0,); if ($time > = 31556926) {$value ["years"] = floor ($time/31556926); $time = ($time%31556926) } if ($time > = 86400) {$value ["days"] = floor ($time/86400); $time = ($time%86400);} if ($time > = 3600) {$value ["hours"] = floor ($time/3600); $time = ($time%3600);} if ($time > = 60) {$value ["minutes"] = floor ($time/60); $time = ($time%60) } $value ["seconds"] = floor ($time); / / return (array) $value; $t=$value ["years"]. " Year ". $value ["days"]. "God". $value ["hours"]. Hours. $value ["minutes"]. "minute". $value ["seconds"]. "seconds"; Return $t;} else {return (bool) FALSE;}} above is all the content of this article "how to turn seconds into time in php". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Time hours content articles methods learning help documents easy to understand more organization environment computers knowledge examples systems editing industry information information channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Redmi Apple Shulou Technology NVidia