3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tz=new DateTimeZone('Europe/Moscow'); $d1=new DateTime('2014-10-26T00:59:59', $tz); $d2=new DateTime('2014-10-26T01:59:59', $tz); var_dump($d2->diff($d1, true)->h); var_dump($d1->add($int=new DateInterval('PT2H'))->format(DateTime::ISO8601), $d2->sub($int)->format(DateTime::ISO8601));

preferences:
28.28 ms | 402 KiB | 5 Q