- substr: documentation ( source)
- end: documentation ( source)
- date: documentation ( source)
- strtotime: documentation ( source)
<?php
$dateFrom = '2015/10/15';
$dateTo = '2015/12/31';
$lastDateList = array();
$fromFirstDay = strtotime('first day of ' . $dateFrom);
while (end($lastDateList) < $dateTo) {
$strYm = date('YYMM', $fromFirstDay);
$ym = substr($strYm,0,4).'-'.substr($strYm,4,2);
$dateLast = date('Y-m-d', strtotime('last day of ' . $ym));
$lastDateList[] = $dateLast;
// 1ヶ月加算
$timeStampFrom = strtotime('+1 month', $fromFirstDay);
};
echo($lastDateList);
?>