3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php public static function dateTimeDiff($start, $end, $units = 'Days') { $start_ts = strtotime($start); $end_ts = strtotime($end); $diff = $end_ts - $start_ts; $divider = 86400; if ($units != 'Days') { $divider = $divider / 24; if ($units != 'Hours') { $divider = $divider / 60; if ($units != 'Minutes') { $divider = $divider / 60; } } } return round($diff / $divider); } $datetime1 = date_create('now'); $datetime2 = date_create('13-11-2013'); $interval = date_diff($datetime1, $datetime2); echo dateTimeDiff(date('Y-m-d'), date_create('13-11-2013')); echo "\n"; echo $interval->format('%R%a dias'); echo "\n".'24-05-2013 (-143 dias)';
Output for 5.4.0 - 5.4.20
Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /in/5nRVe on line 2
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_PUBLIC in /in/5nRVe on line 2
Process exited with code 255.