note 69687 deleted from function.strtotime by derick
| From: | derick@php.net | Date: | Sun, 24 Sep 2006 11:37:37 +0000 |
| Subject: | note 69687 deleted from function.strtotime by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-117492@lists.php.net to get a copy of this message | ||
Note Submitter: sam dot bryan at montal dot com
----
I needed to convert decimal time into hh:mm:ss, but I couldn't find an off the shelf function.
So here's one I prepared earlier:
<?php
// formats decimal time (1.25 hours) into hh:mm:ss (1:15:00)
function fromDecimalTime($dec)
{
$h = (int)$dec;
$s = 3600 * ($dec - $h);
$m = $s/60;
$s = 60 * ($m - (int)$m);
$m = (int)$m;
return sprintf("%d:%02d:%02d", $h, $m, $s);
}
?>