Last active
January 16, 2017 17:05
-
-
Save IgorDePaula/0edf9b11d022121204c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment