This example describes how PHP uses the date and Strtotime functions to output the specified dates. Share to everyone for your reference. The specific methods are analyzed as follows:
The date and Strtotime functions in PHP are all for dates, but it's not the same in the generation that date and strtotime, one is the number date and the other is the Unix timestamp, but we all can generate the same date, and here's a look at two examples of functions.
PHP is often used in the date function and Strtotime function, these 2 functions are not unfamiliar to everyone, today and you share the use of skills.
strtotime-resolves a date-time description of any English text to a Unix timestamp
Copy Code code as follows:
Date_default_timezone_set (' Asia/shanghai ');
Calculate the time of yesterday, we use:
Date ("Ymd", Time ()-3600);
Generate yesterday's time
Date ("Ymd", Strtotime (' Yesterday '));
Date ("Ymd", Strtotime ('-1 day '));
Generate time before the day before
Date ("Ymd", Strtotime (' Yesterday-1 Day '));
Date ("Ymd", Strtotime ('-2 day '));
Build time after 3 days
Date ("Ymd", Strtotime (' +3 Day '));
Generated one months ago
Date ("Ymd", Strtotime ('-1 month '));
Generate the last day of the next month
Date ("Ymd", Strtotime (' Last day of next month ');
Monday, next week.
Date ("Ymd", Strtotime (' next Monday '));
I hope this article will help you with your PHP program design.