1. First get the timestamp of the date through strtotime()
2. Get the timestamp N days ago, through "current timestamp - seconds in N days = timestamp N days ago"
3. Get the timestamp N days ago The timestamp is formatted using the date() function.
Example below: Get the date one day before 2012-5-1
Copy the code The code is as follows:
//Convert the time point For the timestamp
$date = strtotime('2012-5-1');
//Output the date one day ago, subtract the number of seconds of the day from the timestamp
echo date('Y-m-d',$date - 1*24*60*60);
?>
The above introduces the code for adding and subtracting dates within 10 in PHP, including the content of addition and subtraction within 10. I hope it will be helpful to friends who are interested in PHP tutorials.