Home > Backend Development > PHP Tutorial > 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
Release: 2023-04-08 20:34:02
Original
4195 people have browsed it

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
Copy after login

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
Copy after login

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
Copy after login

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!

Related labels:
php
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template