note 50559 added to ref.datetime
| From: | daniel at howes-macnaghten dot com | Date: | Thu, 03 Mar 2005 11:12:05 +0000 |
| Subject: | note 50559 added to ref.datetime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-85863@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/ref.datetime.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50559
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50559&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50559&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50559&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50559&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50559&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50559&report=yes
Search -- http://master.php.net/manage/user-notes.php