php Add one day to the current date and add one day to the specified date, or month, year, etc.

1. Add one day to the current time? One hour

echo "今天:",date('Y-m-d H:i:s'),"<br>";

加
echo "明天:",date('Y-m-d H:i:s',strtotime('+1 day'));


减
echo "明天:",date('Y-m-d H:i:s',strtotime('-1 day'));

2. In the same way, add one year, one hour, one minute, one month 

echo "明天:",date('Y-m-d H:i:s',strtotime('+1 day'));

echo "明天:",date('Y-m-d H:i:s',strtotime('+1 hour'));

echo "明天:",date('Y-m-d H:i:s',strtotime('+1 minute'));

echo "明天:",date('Y-m-d H:i:s',strtotime('+1 mouth'));

Here +1 day can modify parameter 1 to any number you want. Day can also be changed to year (year), month (month), hour (hour) minute (minute), second (second) such as:

date('Y-m-d H:i:s',strtotime("+1 day +1 hour +1 minute");

3. Add one day to the specified time? One hour? .

echo   date("Y-m-d",strtotime("+1 month",strtotime("2012-02-04")));

echo   date("Y-m-d",strtotime("+1 week",strtotime("2011-02-04")));

echo   date("Y-m-d",strtotime("+1 day",strtotime("2011-02-04")));

Guess you like

Origin blog.csdn.net/qq_32450471/article/details/131277567