1日後
$date = new DateTime("2009-10-10");
$date->modify("+1 day");
echo $date->format("Y-m-d");
明日
$date = new DateTime("2009-10-10");
$date->modify("tomorrow");
echo $date->format("Y-m-d");
2日後
$date = new DateTime("2009-10-10");
$date->modify("2days ago");
echo $date->format("Y-m-d");
クラスを使わないやり方。
echo "1日前" . date("Y/m/d", strtotime("-1 day" ));
echo "1ヶ月前" . date("Y/m/d", strtotime("-1 month"));
echo "1年前" . date("Y/m/d", strtotime("-1 year" ));
echo "1週間前" . date("Y/m/d", strtotime("-1 week" ));
echo "1日前" . date("Y/m/d", strtotime("2007/12/20 -1 day" ));
echo "1ヶ月前" . date("Y/m/d", strtotime("2007/12/20 -1 month"));
echo "1年前" . date("Y/m/d", strtotime("2007/12/20 -1 year" ));
echo "1週間前" . date("Y/m/d", strtotime("2007/12/20 -1 week" ));