title: PHP Calculate the remaining time from Login and logout in minutes
body: <p>I am very new to PHP. I have a login system where i am storing the login and logout time in database. My database table is </p>
  
  <pre><code>id        username      password     logintime                            logouttime
  1            test                 test           2014-08-24 13:45:07       2014-08-24 13:45:17
  2            test1               test2         2014-08-24 13:55:07       2014-08-24 13:55:37
  </code></pre>
  
  <p>and using a function i am trying to find the difference between the login and logout time difference in minutes. I tried like</p>
  
  <pre><code>function mytest ($login, $logout, $remaining)
  {
  $query = mysql_query("SELECT * FROM table WHERE logintime ='$login' AND logouttime = '$logout'");
  $retval = mysql_query( $query, $conn );
      if(! $retval )
      {
          die('Could not get data: ' . mysql_error());
      }
      while($row = mysql_fetch_assoc($retval))
      {
          $remaining = $login - $logout;
          echo $remaining;
      }
  
  }
  </code></pre>
  
  <p>but cannot find the result. Please help me in finding out the time difference between two in minutes using function. I surfed for the whole day but couldn't find answer.</p>