note 91336 added to function.date-diff

From: Date: Sat, 06 Jun 2009 20:24:02 +0000
Subject: note 91336 added to function.date-diff
Groups: php.notes 
Request: Send a blank email to php-notes+get-156418@lists.php.net to get a copy of this message
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) ---- Server IP: 69.147.83.197 Probable Submitter: 124.109.18.41 ---- Manual Page -- http://www.php.net/manual/en/function.date-diff.php Edit -- https://master.php.net/note/edit/91336 Del: integrated -- https://master.php.net/note/delete/91336/integrated Del: useless -- https://master.php.net/note/delete/91336/useless Del: bad code -- https://master.php.net/note/delete/91336/bad+code Del: spam -- https://master.php.net/note/delete/91336/spam Del: non-english -- https://master.php.net/note/delete/91336/non-english Del: in docs -- https://master.php.net/note/delete/91336/in+docs Del: other reasons-- https://master.php.net/note/delete/91336 Reject -- https://master.php.net/note/reject/91336 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#156418) next »