This article introduces a time-date conversion custom function in PHP that can be used to convert events representing seconds to years, months, days, hours, and other time formats.
The code is as follows |
Copy Code |
function Sec2time ($time) { if (Is_numeric ($time)) { $value = Array ( "Years" = 0, "days" = 0, "hours" = 0, "Minutes" = 0, "Seconds" and "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; }else{ return (bool) FALSE; } } |
http://www.bkjia.com/PHPjc/631653.html www.bkjia.com true http://www.bkjia.com/PHPjc/631653.html techarticle This article introduces a time-date conversion custom function in PHP that can be used to convert events representing seconds to years, months, days, hours, and other time formats. The code below copies the code F ...