How does php use date to get the day?
This article mainly explains how php uses date to get the first few days. Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "php how to use date to get the day"!
The php date () function can get the day of the year, month or week through the different formatting characters passed in: 1, when the character is "z", you can get the day of the year; 2, when the character is "d" or "j", you can get the day of the month; 3, when the character is "D", "N" or "w", you can get the day of the week.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In PHP, the date () function can format a timestamp to get the day ordinal of a year, month, or week.
Syntax:
Date ("format character" [, timestamp])
The second parameter can be omitted, so it is the current date and time.
There are three types of formatting characters for the day to get:
The day of the year
Z: range 0 to 365
The day of the month
D: 2 digits with leading zeros, ranging from 01 to 31
J: no leading zero, range 1 to 31
The day of the week
D: text representation, 3 letters, ranging from Mon to Sun
The day of the week in N: ISO-8601 format (PHP 5.1.0 added), ranging from 1 (for Monday) to 7 (for Sunday)
W: the number indicates that the range is 0 (for Sunday) to 6 (for Saturday)
Example 1:
Example 2:
Example 3:
At this point, I believe you have a deeper understanding of "php how to use date to get the first few days". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!