一か月後の日付を正しく求める

自分用メモとして記載です。

一般的な例
$raigetuTmp = date('Y-m-d', strtotime('+1 month', strtotime(date('Y-m-d'))));
これは月末だとちゃんと動作しない

来月の1日
$raigetuTmp = date(Y-m-d', strtotime('farst day of next month', strtotime(date('Y-m-d'))));

来月末
$raigetuTmp = date(Y-m-d', strtotime('last day of next month', strtotime(date('Y-m-d'))));

これらをうまく使えばちゃんとできそう

$_raigetu = youbi_make($raigetuTmp);

youbi_make()は自作関数です。

動作結果は
2019年5月16日【木】となりました。
記事id:861 / 3489PV

関連記事