前提・実現したいこと
なぜ$next=$thisMonth->modify(' +1 month')->format('Y-m');
は+1monthされないかがわからない
ここに質問の内容を詳しく書いてください。
(例)PHPでカレンダーなシステムを作っています。
■■な機能を実装中に以下のエラーメッセージが発生しました。
エラーメッセージ
"2018-08" object(DateTime)#2 (3) { ["date"]=> string(26) "2018-08-01 23:50:07.056953" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } string(7) "2018-07" string(7) "2018-08"
該当のソースコード
ソースコード <?php $thisMonth = new Datetime('first day of this month'); $prev=$thisMonth->modify(' -1 month')->format('Y-m'); $next=$thisMonth->modify(' +2 month')->format('Y-m'); var_dump($prev); var_dump($next); exit; php?> ### 結果 "2018-08" object(DateTime)#2 (3) { ["date"]=> string(26) "2018-08-01 23:50:07.056953" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } string(7) "2018-07" string(7) "2018-09" ここに問題に対して試したことを記載してください。 $next=$thisMonth->modify(' +1 month')->format('Y-m'); では9月になってくれません なんでですか ### 補足情報(FW/ツールのバージョンなど) ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー