Skip to content

Instantly share code, notes, and snippets.

@IgorDePaula
Last active January 16, 2017 17:05
Show Gist options
  • Save IgorDePaula/0edf9b11d022121204c8 to your computer and use it in GitHub Desktop.
Save IgorDePaula/0edf9b11d022121204c8 to your computer and use it in GitHub Desktop.
<?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