Jump to content

time diffrence calc problem


GD77

Recommended Posts

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"));

Link to comment
Share on other sites

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
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.