LoginSignup
29
31

More than 5 years have passed since last update.

PHPでサクッと○日後の日付計算

Posted at

今日の日付から3日後を求めたかった。

でも例えば11月29日の3日後等、単純に+3日ではうまくいかないなーと思っていた。

調べたら簡単なやり方があった。

//現在時刻から3日後
echo date("Y-m-d",strtotime("+3 day"));//"2017-12-08"
//特定の日付から3日後
$target_day = "2017-12-05";
echo date("Y-m-d",$target_day.strtotime("+3 day"));//"2017-12-08"

これらを参考にした。
PHP:strtotime
【PHP】指定時間前や指定時間後の日時を求める←詳しいのはココ

29
31
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
29
31