3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php print_r(getMonth(null)); echo ':::'; print_r(getQuarter(null)); echo ':::'; print_r(dtf(null)); function getMonth($d) { return dtf($d,'n'); } function getQuarter($d) { return ceil( getMonth($d) / 3); } function dtf($date, $format = 'd.m.Y'){ if($date) $date = new DateTime($date); return $date->format($format); }
based on 5c6ab
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to a member function format() on null in /in/sT2Ns:22 Stack trace: #0 /in/sT2Ns(11): dtf(NULL, 'n') #1 /in/sT2Ns(3): getMonth(NULL) #2 {main} thrown in /in/sT2Ns on line 22
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Fatal error: Call to a member function format() on null in /in/sT2Ns on line 22
Process exited with code 255.
Output for 5.3.20 - 5.5.35
Fatal error: Call to a member function format() on a non-object in /in/sT2Ns on line 22
Process exited with code 255.