note 26134 deleted from function.microtime by aidan
| From: | aidan@php.net | Date: | Tue, 28 Sep 2004 12:08:17 +0000 |
| Subject: | note 26134 deleted from function.microtime by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77481@lists.php.net to get a copy of this message | ||
Note Submitter: mdchaney at michaelchaney dot com
----
Simple function to return the absolute difference between two microtime strings.
function microtime_diff($a,$b) {
list($a_micro, $a_int)=explode(' ',$a);
list($b_micro, $b_int)=explode(' ',$b);
if ($a_int>$b_int) {
return ($a_int-$b_int)+($a_micro-$b_micro);
} elseif ($a_int==$b_int) {
if ($a_micro>$b_micro) {
return ($a_int-$b_int)+($a_micro-$b_micro);
} elseif ($a_micro<$b_micro) {
return ($b_int-$a_int)+($b_micro-$a_micro);
} else {
return 0;
}
} else { // $a_int<$b_int
return ($b_int-$a_int)+($b_micro-$a_micro);
}
}