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. Use the date() function to convert the format of the timestamp obtained N days ago
The following example: get the date one day before 2012-5-1
Copy code The code is as follows:
//Convert time point to timestamp
$date = strtotime('2012-5 -1');
//Output the date one day ago, subtract the seconds of the day from 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!
http://www.bkjia.com/PHPjc/324668.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324668.htmlTechArticle1. First get the timestamp of the date through strtotime() 2. Get the timestamp N days ago, pass" The current timestamp - the number of seconds in N days = the timestamp N days ago" 3. For the timestamp N days ago, use da...