Php uses the date and strtotime functions to output the method of the specified date, datestrtotime
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
Copy codeThe 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.