Last active
September 25, 2015 08:27
-
-
Save cnicodeme/892200 to your computer and use it in GitHub Desktop.
Format seconds in h:m:s (output can be changed)
This file contains hidden or 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
<?php | |
/** | |
* Create a DateTime object with the number of seconds | |
* Since the date starts at year 0, the returned time will be in year/month/day/hour/minute/second | |
* | |
* @param Integer $iTime : Timestamp in seconds | |
* @param String $sFormat (optional) : The date format to return | |
* | |
* @return String : The well formatted date. | |
*/ | |
function timetostr ($iTime, $sFormat = 'H\hi\ms\s') { | |
$oTime = new DateTime ('@'.$iTime); | |
return $oTime->format ($sFormat); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment