3v4l.org

run code in 300+ PHP versions simultaneously
<?php $startDate = new \DateTime(); $startDate->setDate(2014, 01, 30); $startDate->setTime(0, 0, 0); var_dump($startDate); if ($startDate->format('m') > 28 ) { $startDate->setDate($startDate->format('Y'), $startDate->format('m'), 28; } var_dump($startDate); /* $nextMonth = clone $startDate; $nextMonth->modify('+ 14 days'); $nextMonth->setDate($nextMonth->format('Y'), $nextMonth->format('m'), $nextMonth->format('t')); // $nextMonth->modify('last day of the month'); var_dump($nextMonth); $startDate->add(new DateInterval(sprintf('P%dD', $startDate->format('t')))); $startDate->sub(new DateInterval('P1D')); $startDate->setTime(23, 59, 59); while ($startDate >= $nextMonth) { $startDate->sub(new DateInterval('P1D')); } var_dump($startDate); $newDate = new \DateTime(); $newDate->setDate(2014, 02, 27); $newDate->setTime(23, 59, 59); var_dump($newDate->getTimestamp() == $startDate->getTimestamp()); */
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.34
Parse error: syntax error, unexpected ';' in /in/pTWFY on line 7
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/pTWFY on line 2 Parse error: syntax error, unexpected ';' in /in/pTWFY on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/pTWFY on line 2 Parse error: parse error, unexpected ';' in /in/pTWFY on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/pTWFY on line 2 Parse error: parse error in /in/pTWFY on line 7
Process exited with code 255.

preferences:
222.64 ms | 1386 KiB | 124 Q