3v4l.org

run code in 300+ PHP versions simultaneously
<?php $vencimento = 30; $firstPag = '30/01/2015'; $parcelas = 15; $data = new DateTime(implode('-', array_reverse(explode('/', $firstPag))) . ' 00:00:00'); $data_parcelas = array(); while ($parcelas) { $mes = $data->sub(new DateInterval('P2D'))->add(new DateInterval('P1M'))->format('n'); if ($mes == 2) { $data_parcelas[] = $data->format('d/m/Y'); $data->add(new DateInterval('P2D')); } else { $data_parcelas[] = $data->add(new DateInterval('P2D'))->format('d/m/Y'); } $parcelas--; } echo '<pre>'; print_r($data_parcelas);
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
<pre>Array ( [0] => 28/02/2015 [1] => 30/03/2015 [2] => 30/04/2015 [3] => 30/05/2015 [4] => 30/06/2015 [5] => 30/07/2015 [6] => 30/08/2015 [7] => 30/09/2015 [8] => 30/10/2015 [9] => 30/11/2015 [10] => 30/12/2015 [11] => 30/01/2016 [12] => 28/02/2016 [13] => 30/03/2016 [14] => 30/04/2016 )
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::sub() in /in/tHuJ9 on line 9
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/tHuJ9 on line 6
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/tHuJ9 on line 9
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
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/tHuJ9 on line 9
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/tHuJ9 on line 9
Process exited with code 255.

preferences:
336.04 ms | 401 KiB | 459 Q