In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how php converts the number of seconds into hours and seconds, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let's take a look at it.
Php converts the number of seconds into hours and seconds: 1, through the "function changeTimeType ($seconds) {...}" method to convert the number of seconds into hours and seconds; 2, through the "function Sec2Time ($time) {...}" method to convert the number of seconds into annual days and seconds.
Operating environment of this article: Windows7 system, PHP7.1 version, Dell G3 computer
How does php convert seconds into hours and seconds?
PHP converts seconds to hours, minutes and seconds
One:
/ * convert seconds to hours and seconds * * @ param seconds $seconds * @ return void * / function changeTimeType ($seconds) {if ($seconds > 3600) {$hours = intval ($seconds / 3600); $time = $hours. ":" Gmstrftime ('% time% slots, $seconds);} else {$time = gmstrftime ('% Hpurs% Mpurs% slots, $seconds);} return $time;}
Two:
/ * converted to annual days and seconds * * @ param [type] $time * @ return void * / function Sec2Time ($time) {if (is_numeric ($time)) {$value = array ("years" = > 0, "days" = > 0, "hours" = > 0, "minutes" = > 0, "seconds" = > 0,); $t ='' If ($time > = 31556926) {$value ["years"] = floor ($time / 31556926); $time = ($time% 31556926); $t. = $value ["years"]. Year;} if ($time > = 86400) {$value ["days"] = floor ($time / 86400); $time = ($time% 86400); $t. = $value ["days"]. "days";} if ($time > = 3600) {$value ["hours"] = floor ($time / 3600); $time = ($time% 3600); $t. = $value ["hours"]. Hours;} if ($time > = 60) {$value ["minutes"] = floor ($time / 60); $time = ($time% 60); $t. = $value ["minutes"]. "points";} $value ["seconds"] = floor ($time); / / return (array) $value; $t. = $value ["seconds"]. "seconds"; return $t;} else {return (bool) false;}} Thank you for reading this article carefully. I hope the article "php how to convert seconds into hours and seconds" shared by the editor will be helpful to you. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.