Created
March 2, 2015 20:17
-
-
Save sjs/b64f6e2bdf2c88dabfbd to your computer and use it in GitHub Desktop.
niceseconds.php
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 niceseconds($ss) { | |
$s = $ss%60; | |
$m = floor(($ss%3600)/60); | |
$h = floor(($ss%86400)/3600); | |
$d = floor(($ss%2592000)/86400); | |
$M = floor($ss/2592000); | |
$response = ''; | |
if($M != 0) { $response .= "$M months, "; } | |
if($d != 0) { $response .= "$d days, "; } | |
if($h != 0) { $response .= "$h hours, "; } | |
if($m != 0) { $response .= "$m minutes, "; } | |
if($s != 0) { $response .= "$s seconds, "; } | |
return rtrim($response, ', '); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment