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:
<?php$seconds = "56789"; $output = Secstostr ($seconds); Echo $output; >
The above is the conversion of PHP to the number of days, hours and minutes of content, more relevant content please follow the PHP Chinese web
Related tools: Unix timestamp conversion Tool HTTP://WWW.PHP.CN/XIAZAI/TOOL/5
Related articles:
Time conversion in JS-a sample code that converts milliseconds into a datetime
PHP converts seconds to days, hours, and minutes to format time