Created
September 9, 2013 12:52
-
-
Save light9/6495175 to your computer and use it in GitHub Desktop.
This is a simple PHP code that converts a number of seconds into a string according to the following format: M d h m s. Number of months is an approx calculation supposing months are 30 days long.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function seconds2human($ss) { | |
$s = $ss%60; | |
$m = floor(($ss%3600)/60); | |
$h = floor(($ss%86400)/3600); | |
$d = floor(($ss%2592000)/86400); | |
$M = floor($ss/2592000); | |
return "$M months, $d days, $h hours, $m minutes, $s seconds"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment