Get the App
SLTechnology News&Howtos  ›  Development  › 

How does php get the day of the week when the specified date is?

Shulou Source: shulou.com Published: 2022-06-02 09:31:52 11月12日 Update

This article mainly explains "php how to get the specified date is the day of the week". The explanation in the article is simple and clear and easy to learn and understand. please follow the editor's train of thought to study and learn "php how to get the specified date is the day of the week"!

Acquisition method: 1, define "array (" 7 "," 1 "," 2 "," 3 "," 4 "," 5 "," 6 ") array; 2, use" date ("w", strtotime ("specified date") ") to convert the date into a number of days of the week; 3, take the number as the subscript and take the corresponding day value in the array.

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

Php gets the day of the week on which the specified date is

Determine the day of the week on which the specified date is, that is, what day of the week it is.

We can do this using date ("w", strtotime ("specified date"); but the return value of this statement is: a number indicating the day of the week (0 for Sunday [Sunday], 6 for Saturday [Saturday]).

We can create an array like this:

Array ("seven", "one", "two", "three", "four", "five", "six")

Take the return value of the above date () statement as the subscript and fetch the corresponding day value of the week in the array.

Let's look at the implementation code:

Thank you for your reading, the above is the content of "how to get the specified date is the day of the week". After the study of this article, I believe you have a deeper understanding of how php gets the day of the week, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Date week array number study subscript content numerical value statement that is code that is ideas situations tutorials articles methods more environment computer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL MariaDB Docker Redmi Linux