How to change seconds to time by php
Editor to share with you how php turns the number of seconds to time, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. Create a sample PHP file.
2. Convert the number of seconds to time through the "function Sec2Time ($time) {...}" method.
Example
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 the article "how to turn seconds into time". 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!