This article describes how to use the date and strtotime functions of php to output the specified date. The example summarizes the methods used to generate various date formats, which is very useful. For more information, see
This article describes how to use the date and strtotime functions of php to output the specified date. The example summarizes the methods used to generate various date formats, which is very useful. For more information, see
This example describes how php outputs a specified date using the date and strtotime functions. Share it with you for your reference. The specific method is analyzed as follows:
In php, the date and strtotime functions operate on the date, but the date and strtotime functions are different in the generation process. One is the numeric date and the other is the Unix timestamp, but we can all generate the same date. Let's look at two examples of functions below.
The date and strtotime functions are often used in php. These two functions are certainly not unfamiliar to everyone. I would like to share with you the tips for using them today.
Strtotime-parses the date and time descriptions of any English text into Unix timestamps
The Code is as follows:
Date_default_timezone_set ('Asia/Shanghai ');
// Calculate the time of yesterday. We use:
Date ("Ymd", time () to 3600 );
// Generate the time of yesterday
Date ("Ymd", strtotime ('yesterday '));
Date ("Ymd", strtotime ('-1 Day '));
// Generate the day before yesterday
Date ("Ymd", strtotime ('Yesterday-1 Day '));
Date ("Ymd", strtotime ('-2 Day '));
// Generate three days later
Date ("Ymd", strtotime ('+ 3 Day '));
// Generate a month ago
Date ("Ymd", strtotime ('-1 month '));
// Generate the last day of the next month
Date ("Ymd", strtotime ('Last day of next month '));
// Monday of the next week
Date ("Ymd", strtotime ('Next Monday '));
I hope this article will help you with PHP programming.