WordPress:Template Tags/the date
Description
描述
Displays or returns the date of a post, or a set of posts if published on the same day.
如果文章都是以同样的方式发表的,显示或者返回一篇文章或者一组文章的发表日期。
This tag must be used within WordPress:The Loop.
必须在The Loop内部使用这个标签。
Usage
%%% <?php the_date('format', 'before', 'after', echo); ?> %%%
用法
%%% <?php the_日期('格式', '之前', '之后', echo); ?> %%%
Examples
Default Usage
Displays the date using defaults.
<p>Date posted: <?php the_date(); ?></p>
例子
默认用法
使用默认格式,显示日期。
<p>文章发表的日期: <?php the_日期(); ?></p>
Date as Year, Month, Date in Heading
标签中的年,月,日,日期
Displays the date using the '2007-07-23'
format (ex: 2004-11-30), inside an <h2> tag.
使用'2007-07-23'
格式 (例如: 2004-11-30)显示日期,在<h2>标签内部。
<?php the_date('Y-m-d', '<h2>', '</h2>'); ?>
<?php the_日期('Y-m-d', '<h2>', '</h2>'); ?>
Date in Heading Using $my_date Variable
标题中的日期,使用$my_date 变数
Returns the date in the default format inside an <h2> tag and assigns it to the $my_date variable. The variable's value is then displayed with the PHP echo command.
在<h2>标签中,将日期返回为默认格式,并且将日期分发给$我的_日期变数。变数的值,就会与PHP echo命令行一起显示。
<?php $my_date = the_date('', '', '', FALSE); echo $my_date; ?>
<?php $我的_日期 = the_日期('', '', '', 错误的); echo $我的_日期; ?>
Parameters
参数
- format
- (string) The format for the date. Defaults to the date format configured in your WordPress options. See WordPress:Formatting Date and Time.
- before
- (string) Text to place before the date. There is no default.
- after
- (string) Text to place after the date. There is no default.
- echo
- (boolean) Display the date (TRUE), or return the date to be used in PHP (FALSE). Defaults to TRUE.
- 格式:(string)日期的格式。默认为WordPress选项中设置的日期格式。请看看日期和时间格式。
;之前:(string)置于日期前的文本。没有默认设置。 ;之后:(string)置于日期后的文本。没有默认设置。
- echo
- (boolean)显示日期(正确的),或者返回日期用于PHP(错误的)。默认为正确的。