PHP converts seconds to days, hours, and minutes PHP converts seconds to days, hours, and minutes:
Function secsToStr ($ secs) {if ($ secs> = 86400) {$ days = floor ($ secs/86400); $ secs = $ secs % 86400; $ r = $ days. 'day'; if ($ days <> 1) {$ r. ='s ';} if ($ secs> 0) {$ r. = ',' ;}} if ($ secs >=3600) {$ hours = floor ($ secs/3600); $ secs = $ secs % 3600; $ r. = $ hours. 'hour'; if ($ hours <> 1) {$ r. ='s ';} if ($ secs> 0) {$ r. = ',' ;}} if ($ secs >=60) {$ minutes = floor ($ secs/60); $ secs = $ secs % 60; $ r. = $ minutes. 'Minute '; if ($ minutes <> 1) {$ r. ='s ';} if ($ secs> 0) {$ r. = ',' ;}}$ r. = $ secs. 'second'; if ($ secs <> 1) {$ r. ='s ';} return $ r ;}
Usage:
The above section describes how PHP converts seconds to days, hours, and minutes. For more information, see the first PHP community.
Related tools: Unix timestamp conversion tool # xiazai/tool/5
Related articles:
Sample code for converting time from millisecond to date in js
PHP converts seconds to days, hours, and minutes.