GD77 Posted July 12, 2012 Share Posted July 12, 2012 Hello, I m using the following fuction to calculate the time difference between 2 stops...Working well till I ve noticed when one of the stops was am the second was pm I got -987 as result:/ function timeDiff($T_old, $T_new) { $timeCalc = strtotime($T_new) - strtotime($T_old); $timeCalc = round($timeCalc/60); return $timeCalc; } $res=$this->timeDiff($fetch_LA_time, date("h:i:s")); Quote Link to comment Share on other sites More sharing options...
Barand Posted July 12, 2012 Share Posted July 12, 2012 If only times are used, with no date info, times are assumed to be today <?php function timeDiff($T_old, $T_new) { $timeCalc = strtotime($T_new) - strtotime($T_old); $timeCalc = round($timeCalc/60); return $timeCalc; } echo timeDiff('16:54:00', date("h:i:s")); //--> -293 echo '<br />'; echo timeDiff('2012-07-11 16:54:00', date("h:i:s")); //--> 1147 ?> Quote Link to comment Share on other sites More sharing options...
GD77 Posted July 12, 2012 Author Share Posted July 12, 2012 hanks a lot, worked like a charm Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.