WordPress:Template Tags/the time

来自站长百科
跳转至: 导航、​ 搜索

描述[ ]

显示当前文章的发表时间。必须在The Loop内使用这个标签。

用法[ ]

%%% <?php the_time('d'); ?> %%%

例子[ ]

默认用法[ ]

使用WordPress默认设置,显示时间。

<p>Time posted: <?php the_time(); ?></p>

上午/下午标记的时间格式和24小时的时间格式[ ]

使用格式参数string '上午09:18 ' (例如: 下午10:36)显示时间。

<p>Time posted: <?php the_time('g:i a'); ?></p>


使用24小时制时间格式参数string 'G:i' (例如: 17:52)显示时间。

<p>Time posted: <?php the_time('G:i'); ?></p>

按年,月,日格式组合的日期[ ]

以日期格式'F j, Y' (例如: 2004年12月2日),这个格式可以用来代替标签the_date()

<div><?php the_time('F j, Y'); ?></div>

日期和时间[ ]

显示日期和时间。

<p>Posted: <?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?></p>
发表时间: 2007年7月17日上午 7:19

参数[ ]

d
(string)显示时间的格式。默认为WordPress选项中设置的时间格式。请看看日期和时间格式

相关的[ ]

模板:标签日期标签