note 91336 deleted from function.date-diff by danbrown
| From: | danbrown@php.net | Date: | Mon, 08 Jun 2009 12:41:40 +0000 |
| Subject: | note 91336 deleted from function.date-diff by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-156460@lists.php.net to get a copy of this message | ||
Note Submitter: kaysar in ymail in com
----
Hey friend... i've made some changes here to
avoid... (i guess...) exponential values produced
by division (to convert sec to hrs)...
<?php
function GetTimeDiff($dt1, $dt2)
{
//format () was giving me fetal errors so i avoided it
//-------------------------
//$nUXDate1 = strtotime($dt1->format("Y-m-d H:i:s"));
//$nUXDate2 = strtotime($dt2->format("Y-m-d H:i:s"));
//------------------------
$nUXDate1 = strtotime($dt1);
$nUXDate2 = strtotime($dt2);
$nUXDelta = $nUXDate1 - $nUXDate2;
/*********** better avoide this part *************
$strDeltaTime = "" . $nUXDelta/60/60; // sec -> hour
$nPos = strpos($strDeltaTime, ".");
if ($nPos !== false)
$strDeltaTime = substr($strDeltaTime, 0, $nPos - 1);
return $strDeltaTime;
*********************************************/
return $nUXDelta;//is in sec
}
?>
to compare this return value convert the duretion,
say 24hrs, to secs, like (24*60*60)