Home>Article>Backend Development> How to implement date in php to only display year, month and day

How to implement date in php to only display year, month and day

WJ
WJ Original
2020-06-09 17:06:41 3942browse

How to implement date in php to only display year, month and day

How to realize that the date in php only displays the year, month and day?

echo date('Y-m-j'); 2020-02-6 echo date('y-n-j'); 20-2-6

Uppercase Y represents the four-digit year, while lowercase y represents the two-digit year;
Lowercase m represents the number of the month (with leading), while lowercase n represents without the leading month number.

echo date('Y-M-j'); 2020-Feb-6 echo date('Y-m-d'); 2020-02-06

Uppercase M represents the 3 abbreviated characters of the month, while lowercase m represents the number of the month (with leading 0);
There is no uppercase J, only lowercase j represents the date of the month, No leading o; if a leading month is required, use a lowercase d.

echo date('Y-M-j'); 2007-Feb-6 echo date('Y-F-jS'); 2007-February-6th

Capital M represents the 3 abbreviated characters of the month, while capital F represents the full English version of the month. (No lowercase f)
Capital S represents the suffix of the date, such as "st", "nd", "rd" and "th", depending on the date number.

Summary:
can represent the year with uppercase Y and lowercase y;
can represent the month with uppercase F, uppercase M, lowercase m and lowercase n (two ways to represent characters and numbers respectively) );
can use lowercase d and lowercase j to represent the day, and uppercase S represents the suffix of the date.

Related recommendations:php tutorial

The above is the detailed content of How to implement date in php to only display year, month and day. 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