fork download
  1. <?php
  2. $val1 = '2015-04-17 14:00';
  3. $val2 = '2015-04-18 00:00';
  4.  
  5. $datetime1 = new DateTime($val1);
  6. $datetime2 = new DateTime($val2);
  7.  
  8. $intervalo = $datetime1->diff($datetime2);
  9.  
  10. echo '<pre>';
  11. print_r($intervalo);
  12.  
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
<pre>DateInterval Object
(
    [y] => 0
    [m] => 0
    [d] => 0
    [h] => 10
    [i] => 0
    [s] => 0
    [weekday] => 0
    [weekday_behavior] => 0
    [first_last_day_of] => 0
    [invert] => 0
    [days] => 0
    [special_type] => 0
    [special_amount] => 0
    [have_weekday_relative] => 0
    [have_special_relative] => 0
)