note 54609 deleted from function.date by aidan
| From: | aidan@php.net | Date: | Sun, 31 Jul 2005 12:31:56 +0000 |
| Subject: | note 54609 deleted from function.date by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-92812@lists.php.net to get a copy of this message | ||
Note Submitter: m0oseman at hotmail dot com
----
Say you need to know what time is 14% of 8hrs:
$time = "08:00:00";
$percent = "14";
function PercentOfTime($time, $percent){
$timedec = explode(":", $time);
$hours = $timedec[0] * 60 * 60;
$minute = $timedec[1] * 60;
$sec = $timedec[2];
$timesec = $hours + $minute + $sec;
$timesec = $timesec * ($percent / 100);
$sec = ($timesec) % 60;
$min = ($timesec / 60) % 60;
$hr = ($timesec / (60 * 60)) % 60;
return date("H:i:s", (strtotime($hr . ":" . $min . ":" . $sec)));
}