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

Php date () gets how to remove zeros from the month

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

Share

Shulou(Shulou.com)06/03 Report--

Php date () gets how to remove zero from the month. For this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

In php, you can get the month without zero by changing the parameter to "n" by date () and removing zero. The complete code is "echo date ('n');".

This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer

How does php date () get the month off zero?

The problem of getting the month with or without 0 by the date () function in PHP

Recently, I encountered the problem of getting months with or without zeros when using date () in the code. I have solved this problem before, but I have forgotten it. I have written it down so that I can see later that I hope I can help my friends in need.

1. 0 when the letter is lowercase m

Echo date ('m') 05

2. No 0 when the letter is lowercase n

Echo date ('n'); 5

Here are some detailed explanations of some parameters used in the date () function:

A-"am" or "pm"

A-"AM" or "PM"

D-several days, double digits, if less than two digits, the preceding zero; for example: "01" to "31"

D-what day of the week, three English letters; such as "Fri"

F-month, full name in English; for example: "January"

H-12 hours; for example: "01" to "12"

H-24 hours; e. G. "00" to "23"

G-12 hours, less than two do not fill zero; for example: "1" to 12 "

G-24 hours, less than two do not fill zero; for example: "0" to "23"

I-minutes; for example: "00" to "59"

J-a few days, double digits, if less than two digits do not fill zero; for example: "1" to "31"

L-day of the week, full name in English, such as "Friday"

M-month, double digits, if less than two digits, fill in the preceding zero; for example, "01" to "12"

N-month, double digits, if less than two digits, no zero; for example: "1" to "12"

M-month, three English letters; e. G. "Jan"

S-seconds; for example: "00" to "59"

S-suffix plus ordinal, two letters, such as "th", "nd"

T-specify the number of days of the month; for example: "28" to "31"

U-Total seconds

W-numeric day of the week, such as "0" (Sunday) to "6" (Saturday)

Y-year, four digits; for example: "1999"

Y-year, double digit; e. G. "99"

Z-the day ordinal of the year; for example, "0" to "365"

This is the answer to the question about how to get rid of zero in php date (). I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

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