title: php: datetime() difference between 2 datetime with 2 variables
body: <p>I have in my database 4 columns which are:</p>
  
  <pre><code>Date_in | Time_in | Date_out | Time_out
  </code></pre>
  
  <p>Date_in and Time_in belong together (e.g., 2013-02-18 13:00:00) and date_out goes with Time_out. I would like to find out the difference between and I have gotten up till:</p>
  
  <pre><code>$start_time = new DateTime("'$list[date_in] "."$list[time_in]'");
  $since_start = $start_time-&gt;diff(new DateTime("'$list[date_out] "."$list[time_out]'"));
  
  $hours = $since_start-&gt;h.' hours';
  </code></pre>
  
  <p>But it doesn't work. I think my quotes and double quotes are all messed up because the use of <strong>" ' .</strong> really confuses me..</p>
  
  <p>Thanks in advance for any advice on how I can fix my code!</p>
  
  <p>[EDIT]
  Thanks everyone for all your detailed help! I just realised that the server doesn't support php 5.3 and I can't use datetime(). </p>
  
  <p>So my solution was:</p>
  
  <pre><code>$start_time = strtotime("$list[date_in] " . "$list[time_in]");
  $end_time = strtotime("$list[date_out] " . "$list[time_out]");
  $hours = abs(($end_time - $start_time)/3600);
  </code></pre>