title: PHP getting TIME difference in hours and minutes format
body: <p>I'm currently new to PHP , and I am stuck on this problem. I cant seem to subtract the <code>TIME IN</code> from employee SCHEDULE</p>
  <pre><code>function update_dtr($rs) {
  
      foreach ($rs as $key =&gt; $value) {
  
          $db=new Database ();
          $db-&gt;connect();
  
          //date_default_timezone_set('Asia/Ho_Chi_Minh');
          $empShift = $db-&gt;select(array('myilogin_46.DATE_TIME_RECORDS'),'SHIFT_START'
          ,&quot;ID = '&quot;.$id.&quot;' and R_STATUS = 'A'&quot;);
  
        
          $sched= strtotime($empshift);
          $alterin = strtotime($value['alterIN']);
          if($sched&gt;$alterin){
              $late= strtotime(&quot;00:00:00&quot;);
  
          }else{
              //subtract Alterin by the scedule so i can get late in hours and minutes format
              $late = $alterin - $sched;
          }
  
          $db-&gt;update_imp('myilogin_46.DATE_TIME_RECORDS',array(
                  'date_in'=&gt;date('Y-m-d',strtotime($value['alterIN']))
                  ,'time_in_info'=&gt;'ALTERED IN'
                  ,'time_out_info'=&gt;'ALTERED OUT' 
                  ,'time_in'=&gt;date('H:i',strtotime($value['alterIN']))
                  ,'time_out'=&gt;date('H:i',strtotime($value['alterOUT']))
                  ,'date_out'=&gt;date('Y-m-d',strtotime($value['alterOUT']))
                  ,'late'=&gt;gmdate('H:i',strtotime($late))
          ),&quot;id = '&quot;.$value['dtrID'].&quot;' and id_emp = '&quot;.$value['empID'].&quot;' and R_STATUS = 'A'&quot;);
          $db-&gt;disconnect();
  </code></pre>
  <p>PS: I also tried date_diff method, but it doesn't work on me.
  <a href="https://i.stack.imgur.com/fJTts.png" rel="nofollow noreferrer">THis is what my database looks like</a></p>
  <p><a href="https://i.stack.imgur.com/ZVN2g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZVN2g.png" alt="enter image description here" /></a></p>