Function Reference/the time

来自WordPress中文文档
(重定向自Template Tags/the time
跳转至: 导航搜索

wordpress.org.cn

Description

Displays the time of the current post. This tag must be used within The Loop.

Usage

%%% ?php the_time( $d ); ? %%%

Parameters

tt$d/tt
(string) (optional) The format the time is to display in. Defaults to the time format configured in your WordPress options. See Formatting Date and Time.
Default: Nonenoinclude

div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9

Notes

This template is for standardizing how parameters look in the Function Reference and in Template Tags. Here is an example of this template being called: prenowiki检查到模板循环:模板:Parameter/nowiki/pre 检查到模板循环:模板:Parameter

The usage of this template is below: prenowiki检查到模板循环:模板:Parameter/nowiki/pre Let's take a closer look at the parameters..

name
The name of the parameter.
datatype
The datatype that should be given for this parameter when called.
  • string
  • integer
  • boolean
  • mixed
description
A short description of the parameter.
importance
Set this parameter to optional if the parameter is optional. Otherwise, do not declare this parameter—it defaults to required.
  • required
  • optional
default
If this parameter is optional, ttdefault/tt is the value that will be used if the parameter is not declared.

wordpress.org.cn /div /noinclude

Examples

Default Usage

Displays the time using your WordPress defaults.

pTime posted: ?php the_time(); ?/p

Time as AM/PM VS. 24H format

Displays the time using the format parameter string tt'09:18 am'/tt (ex: 10:36 pm).

lt;pgt;Time posted: ?php the_time('g:i a'); ?lt;/pgt;

--

Displays the time using the 24 hours format parameter string tt'G:i'/tt (ex: 17:52).

lt;pgt;Time posted: ?php the_time('G:i'); ?lt;/pgt;

Date as Month Day, Year

Displays the time in the date format tt'F j, Y'/tt (ex: December 2, 2004), which could be used to replace the tag the_date().

lt;divgt;?php the_time('F j, Y'); ?lt;/divgt;

Date and Time

Displays the date and time.

lt;pgt;Posted: ?php the_time('F j, Y'); ? at ?php the_time('g:i a'); ?lt;/pgt;

div style=border:1px solid blue; width:50%; padding:10pxPosted: July 17, 2007 at 7:19 am/div

Related

get_calendar, get_day_link, get_month_link, get_the_date, get_the_time, get_year_link, single_month_title, the_date, the_date_xml, the_modified_author, the_modified_date, the_modified_time, the_time

includeonlydiv style=clear:both; background-color:#F7F7F7; border:1px solid #CCCCCC; color:#000000; padding:7px; margin:0.5em auto 0.5em auto; vertical-align:middle;See also index of Function Reference and index of Template Tags./div/includeonlynoinclude

Description

This Template is used by Codex:Template Messages.

Usage

pre 检查到模板循环:模板:Message /pre

Result

检查到模板循环:模板:Message

/noinclude