3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $frequency = 'weekly'; // If its daily we only run the cron once a day so send if ($frequency === 'daily') { return true; } try { $startDate = new DateTime('2014-11-15 00:00:00'); $now = new DateTime(2014-11-22 00:00:00); // Get the diff between the two dates $diff = $now->diff($startDate); if ($frequency === 'weekly') { $daysDiff = (int) $diff->format('%d'); echo $daysDiff % 7 === 0 ? 'true' : 'false'; } else { $monthDiff = explode(',', $diff->format('&m,%d')); if ($monthDiff[0] > 0 && $monthDiff[1] != 0) { echo 'true'; } } } catch (Exception $e) { // TODO: Better error handling ... Log it :) return false; }
based on RRuhR
Output for 5.4.0 - 5.4.35
Parse error: syntax error, unexpected '00' (T_LNUMBER) in /in/vddUE on line 12
Process exited with code 255.
Output for 5.1.0 - 5.3.29
Parse error: syntax error, unexpected T_LNUMBER in /in/vddUE on line 12
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_LNUMBER in /in/vddUE on line 12
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '{' in /in/vddUE on line 10
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '{' in /in/vddUE on line 10
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/vddUE on line 10
Process exited with code 255.