wordpress <?php the_time() ?>,WordPress自定义时间显示格式,get_the_time()介绍

Certain WordPress tag functions are used to display or return date and time information; the_date() and the_time() are examples of this. Some of these functions accept a parameter called a format string that allows you to determine how the date is going to be displayed. The format string is a template in which various parts of the date are combined (using “format characters”) to generate a date in the format specified.

For example, the format string:l, F j, Y

creates a date that look like this:Friday, September 24, 2004

Here is what each format character in the string above represents:l = Full name for day of the week (lower-case L).

F = Full name for the month.

j = The day of the month.

Y = The year in 4 digits. (lower-case y gives the year’s last 2 digits)(Commas are read literally.)

WordPress is written in the programming language PHP. The date formatting functions in WordPress use PHP’s built-in date formatting functions. You can use the table of date format characters on the PHP website as a reference for building date format strings for use in WordPress. Here is a table of some of the more useful items found there:Day of Month

dNumeric, with leading zeros01–31

jNumeric, without leading zeros1–31

SThe English suffix for the day of the monthst, nd or th in the 1st, 2nd or 15th.

Weekday

lFull name  (lowercase ‘L’)Sunday – Saturday

DThree letter nameMon – Sun

Month

mNumeric, with leading zeros01–12

nNumeric, without leading zeros1–12

FTextual fullJanuary – December

MTextual three lettersJan – Dec

Year

YNumeric, 4 digitsEg., 1999, 2003

yNumeric, 2 digitsEg., 99, 03

Time

aLowercaseam, pm

AUppercaseAM, PM

gHour, 12-hour, without leading zeros1–12

hHour, 12-hour, with leading zeros01–12

GHour, 24-hour, without leading zeros0-23

HHour, 24-hour, with leading zeros00-23

iMinutes, with leading zeros00-59

sSeconds, with leading zeros00-59

TTimezone abbreviationEg., EST, MDT …

Full Date/Time

cISO 86012004-02-12T15:19:21+00:00

rThu, 21 Dec 2000 16:01:07 +0200

Examples

Here are some examples of date format and result output.F j, Y g:i a – November 6, 2010 12:50 am

F j, Y – November 6, 2010

F, Y – November, 2010

g:i a – 12:50 am

g:i:s a – 12:50:48 am

l, F jS, Y – Saturday, November 6th, 2010

M j, Y @ G:i – Nov 6, 2010 @ 0:50

Y/m/d \a\t g:i A – 2010/11/06 at 12:50 AM

Y/m/d \a\t g:ia – 2010/11/06 at 12:50am

Y/m/d g:i:s A – 2010/11/06 12:50:48 AM

Y/m/d – 2010/11/06

Combined with the_time() template tag, the code below in the template file:This entry was posted on <?php the_time('l, F jS, Y') ?> and is filed under <?php the_category(', ') ?>.

will be shown on your site as following:This entry was posted on Friday, September 24th, 2004 and is filed under WordPress and WordPress Tips.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值