In the use of WordPress process, often need to format the date of WordPress, in PHP format or Date function is date (), but in WordPress using the The_time () function to format the WordPress time and date, Their usage is essentially the same, but The_time () is the direct output, and the date () function is the return time string.
Parameter description
Parameter parameter description output time format
D Date 06
J Date 6
D Monday
F Month January
G-hour 6
G-hour 06
H minutes 6
H minutes 06
A last afternoon am/pm
A last Afternoon am/pm
L Monday Week
M month 01
M months of the month
N Month 6
O Time Zone +0800
R Full Date Time Mon 2010 20:30:10 +0800
Suffix st/th of S-sequence numbers
T Time Zone CST
W Week 2
W Week number 22
Y Year 10
Y Year 2010
Z Days 365
Using the sample
Chinese date format setting, Month Day: such as: February 1, 2010
The_time (' Y year n Month J Day ');
Chinese time setting, Hours: 22:22:22
The_time (' g:i:s ');
Week format setting, week: Thursday, November 1, 2010
The_time (' Y year n month J Day L ');
Of course, sometimes our theme like Chinese and English mixed date display format, for the use of WordPress, this will make some small adjustments. Here, for example, the month in which the log time is displayed, we use The_time (' M ') in the topic to print out the English abbreviated month value for a Sep.
But fortunately and unfortunately, WordPress will be very humane for you to translate into nine, said lucky because of the intelligent WordPress people feel happy, said unfortunately because I really need Sep such as the English shorthand format, which let me how to be good.
So how do we do this at this time, from the function point of view to solve this problem, reset to avoid the Chinese. The function:
The_time (' M ');
Replace with:
echo Date (' M ', get_the_time (' U '));
This time we find that we have the time format we need.