http://okwave.jp/qa/q8808903.html で質問した、 「15日以上は来月の1日、14日未満は今月の1日を正しく返す処理にしたい」 の続きになります。 以下の文字列を return date('Y-m-01', strtotime('+1 month')); 以下の通り置換します return date('Y-m-01', strtotime('+1 month', strtotime(date('Y-m-01')))); 上記の場合", strtotime(date('Y-m-01'))"の部分を付加したいのです。 "date.*.strtotime.*.month"の条件で、プロジェクトをグレップした結果 以下のようなパターンで対象が存在しました。 <パターン> date("Y-m-d",strtotime("+3 month")); date("Y-m-d",strtotime("-1 month")); date("Y-m-d",strtotime("-6 month")); date('Y-m-01', strtotime('+3 month')); date('Y-m-d 00:00:00', strtotime('-3 month')) date('Y-m-d', strtotime(date('Y-m-1') .' +1 month')); date('Y-m-d', strtotime(date('Y-m-1') .' +1 month')); date('Ym01', strtotime($njDt . ' +1 month')); date('Ym01', strtotime('+2 month')); date('Y年m月', strtotime('+1 month')); date('ym', strtotime($nij . ' +1 month')); date('ym', strtotime(date('Y-m-1') .' +2 month')); date("Y-m-d",strtotime("-1 month")) date('Ym', strtotime('+1 month')) ↓これは、変数を1日に戻す必要がある date("Y-m-01",strtotime("+1 month" ,strtotime($time))); date("Y-m-15",strtotime("-1 month" ,strtotime($time))); date("Y-m-d",strtotime("-1 month" ,strtotime($njd2))); ※↓は置換したくありません。 date("Y", strtotime($month1)) * 12 + date("m", strtotime($month1)); 上記のような条件で、一発で置換できる方法はありますでしょうか。 また、置換した行と、置換した結果が簡単に解る方法も合わせてご教示いただければうれしいです。 置換は、linux(centOS) のsed コマンドを使おうと思っています。 すみませんが解答の程、よろしくお願いいたします。 以上
↧