Anda di halaman 1dari 2

<?

php
/*
$d1='2015-12-01';
$d2='2016-03-08';

$hasil=bulan($d1,$d2);

echo $hasil."<br>";
$b=substr($d1,5,2);
$x=0;

for($aa=0;$aa<$hasil;$aa++){
$a="+".$aa;
$next = date('Y-m-d', strtotime( $a.' month', strtotime($d1)));
$nextb= substr($d1,5,2);
$nextt= substr($d1,0,4);
echo $next."<br>";
}
*/
$tahun='2016';
$bln='01';
$tgl= $tahun."-".$bln."-01";
$skrg=date('Y-m-d');
$tglup=intval(bulan($tgl,$skrg))+3;

for($z=0;$z<$tglup;$z++){

$c="+".$z;
$next = date('Y-m-d', strtotime( $c.' month', strtotime($tgl)));
$nextb= substr($next,5,2);
$nextt= substr($next,0,4);

echo $tgl."---".$tglup."---".$next."<br>";
}

function bulan($d1,$d2){
$differenceFormat='%m';

$datetime1 = date_create($d1);
$datetime2 = date_create($d2);

$interval = date_diff($datetime1, $datetime2);

return $interval->format($differenceFormat)+1;
}
?>

Anda mungkin juga menyukai