Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does php use date to get the day?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report