Home > Article > Backend Development > How to get the date of next week in php
How to get the date of next week: 1. Use the "strtotime("next specified week")" statement to get the timestamp of the specified week of next week; 2. Use "date("Y-m-d", timestamp) " statement converts the obtained timestamp into a date and uses echo to output it.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
PHP Get next week How to get the date:
1. Create a new php file, named test.php, to explain how php gets the date of next Thursday.
#2. In the test.php file, use the header() method to set the encoding format of the page to utf-8 to avoid garbled characters when the page outputs Chinese.
#3. In the test.php file, define a string in the format of "next week".
4. In the test.php file, use the strtotime() function to use the string in the previous step to obtain the timestamp of the next Thursday date.
5. In the test.php file, use the date() function to convert the timestamp into a date, and use echo to output the conversion result.
6. Open the test.php file in the browser and view the results.
Summary:
1. Define a string in the format of "next week".
2. Use the strtotime() function to use the string in the previous step to obtain the timestamp of the next Thursday date.
3. Then use the date() function to convert the timestamp into a date, and use echo to output the conversion result.
If you are interested, you can click on "PHP Video Tutorial" to learn more about PHP knowledge.
The above is the detailed content of How to get the date of next week in php. For more information, please follow other related articles on the PHP Chinese website!