note 50559 deleted from ref.datetime by didou
| From: | didou@php.net | Date: | Thu, 03 Mar 2005 17:06:04 +0000 |
| Subject: | note 50559 deleted from ref.datetime by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-85874@lists.php.net to get a copy of this message | ||
Note Submitter: daniel at howes-macnaghten dot com
Reason: bad code
----
Have just been writing some payslips and have needed to convert the number of seconds a person has
worked daily and weekly into the number of hours and minutes (hh.mm).
On a per day basis the date("G.i", $iSeconds) can be used (as a person cannot work more
than 24 hours in a day !) but for weekly totals the above date function wraps over days. I wrote
this little function to display a nice hh.mm format for durations > 86400 seconds.
function seconds_to_hrs_mins_string($iSeconds)
{
$iMins = floor(($iSeconds % 3600)/60);
$iMins = ($iMins < 10 ? '0'.$iMins : $iMins);
$iHrs = floor($iSeconds/3600);
return $iHrs.'.'.$iMins;
}
Hope it might prove useful to someone.