![[PHP] 翌日や1週間後、1ヶ月後の日付を求める方法](http://blog.diginnovation.com/wp-content/uploads/2013/08/php_tomorrow_week_month.jpg)
PHPを用いて明日や1週間後、1ヶ月後の日付を求める方法。
詳細は以下から。
翌日や1週間後、1ヶ月後の日付を求める方法
echo "今日 :".date('Y-m-d')."<br />\n";
echo "翌日 :".date('Y-m-d', strtotime('+1 day'))."<br />\n";
echo "1週間後:".date('Y-m-d', strtotime('+1 week'))."<br />\n";
echo "1ヵ月後:".date('Y-m-d', strtotime('+1 month'))."<br />\n";
任意の日付の翌日、1週間後、1ヶ月後を求めたい場合は下記の様に記述します。
//2013-08-01の翌日、1週間後、1ヶ月後を求めたい場合
$year = '2013';
$month ='08';
$day = '01';
$start_date = mktime(0,0,0,$month, $day, $year);
echo "翌日 :".date('Y-m-d', strtotime('+1 day', $start_date))."<br />\n";
echo "1週間後:".date('Y-m-d', strtotime('+1 week', $start_date))."<br />\n";
echo "1ヵ月後:".date('Y-m-d', strtotime('+1 month', $start_date))."<br />\n";


コメント