strtotime関数はGNU Date Input Formats形式に準拠した文字列をタイムスタン プ形式に変えるためのものです。使用方法として、ある時点から何年前、何ヶ月 後、何日前などの日付を計算するためなどに使用できます。月末に実行されるス クリプト内に、strtotime関数を使用していると思わぬ落とし穴にはまることが あるので注意しましょう。 月末に以下のように先月の日付文字列を取得するコードを記述したとします。 $next_month = date('Y-m', strtotime('-1 month')); このコードは3,5,7,10,12月の月末に実行すると、そのまま3,5,7,10,12月が返っ てきてしまいます。これはなぜかというと、3月31日という日付から一ヶ月前を 計算しようとしたときに、2月31日が存在せず、3月3日という日付が返ってきて しまうのが原因のよ