1, first through Strtotime () to obtain the date timestamp
2, get the time stamp N days ago, through the "current timestamp-n days of the number of seconds = n days before the time stamp"
3, to n days before the time stamp with the date () function for format conversion
The following example: Date of the day before the 2012-5-1 number was obtained
Copy the Code code as follows:
Convert a point in time to a timestamp
$date = Strtotime (' 2012-5-1 ');
Output the date of the day, minus the number of seconds in a day on the timestamp
echo Date (' y-m-d ', $date -1*24*60*60);
?>
Output: 2012-4-30
In addition, the time () function gets the timestamp of the current date!
The above introduces the addition and subtraction of PHP within 10 of the date plus subtraction operation implementation code, including the content of the addition and subtraction within 10, I hope to be interested in PHP tutorial friends helpful.