3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 - 7.2.0
<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.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.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.