note 90251 deleted from function.date by danbrown
| From: | danbrown@php.net | Date: | Sun, 12 Apr 2009 17:43:06 +0000 |
| Subject: | note 90251 deleted from function.date by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-153121@lists.php.net to get a copy of this message | ||
Note Submitter: jumutwa at googlemail dot com
----
Don't know if it is already posted, but I guess it can be really useful:
<?php
/**
* sec_to_period(123455677) returns an array of following type:
* Array
(
[years] => 3
[day] => 333
[hours] => 21
[minutes] => 14
[seconds] => 37
)
*
* @param int $sec a period in seconds
* @return array
*/
function sec_to_period($sec){
$return['years']= floor($sec / (60*60*24*365));
$sec = $sec % (60*60*24*365);
$return['day']= floor($sec / (60*60*24));
$sec = $sec % (60*60*24);
$return['hours']= floor($sec / (60*60));
$sec = $sec % (60*60);
$return['minutes']= floor($sec / 60);
$sec = $sec % 60;
$return['seconds']= $sec;
return $return;
}
?>