Home  >  Article  >  Backend Development  >  How to get the date of next week in php

How to get the date of next week in php

WBOY
WBOYOriginal
2021-11-10 14:51:323142browse

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.

How to get the date of next week in php

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.

How to get the date of next week in php

#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.

How to get the date of next week in php

#3. In the test.php file, define a string in the format of "next week".

How to get the date of next week in php

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.

How to get the date of next week in php

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.

How to get the date of next week in php

6. Open the test.php file in the browser and view the results.

How to get the date of next week in php

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn