Get the App
SLTechnology News&Howtos  ›  Development  › 

How to change seconds to time by php

Shulou Source: shulou.com Published: 2022-06-03 10:06:19 10月03日 Update

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!

Tags: Articles time content not much most examples hours documents methods more knowledge examples industry information information channels channels references learning help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Redmi MySQL Microsoft vpn