年末、月末の取得

月末取得

//入力:$month ・・・ 月(1〜12)
$nextMonth = sprintf('%02d', ($month+1));
$nextMonth = (intval($nextMonth)>12)?'01':$nextMonth;
$t = strtotime($regEY . '/' . $nextMonth . '/01 -1 day');// 当月末のタイムスタンプ取得
echo date('Ymd', $t); // YYYYMMDD

年末取得

//入力:$year ・・・ 年
$nextYear = sprintf('%4d', ($year+1));
$t = strtotime($nextYear . '/01/01 -1 day');// 当年末のタイムスタンプ取得
echo date('Ymd', $t); // YYYYMMDD