wordpress时间显示格式

Posted by Danfi on 2010-03-31 添加评论

使用不同的时间函数可以改变格式:
1.the_date_xml()函数
调用语句:

  1. <?php the_date_xml(); ?>

显示格式为:YYYY-MM-DD
例子:2010-03-31

2.the_time()函数
调用语句格式:

  1. <?php the_time( $d ); ?>

例子1:

  1. <?php the_time('g:i a'); ?>

显示格式为:10:36 下午(英文版下显示不同,系统会自动翻译,下面如同

例子2:

  1. <?php the_time('G:i'); ?>

显示格式为: 17:52

例子3:

  1. <?php the_time('F j, Y'); ?>

显示格式为:二月 2, 2010

例子4:

  1. <?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?>

显示格式为:二月 17, 2010 at 7:19 下午

3.the_date()函数
调用语句格式:

  1. <?php the_date( $format, $before, $after, $echo ); ?>

其中:format—时间显示格式。
before—放置在日期前的文本,默认空。
after—放置在日期后的文本,默认空。
echo—布尔值,是否让时间显示,或返回供 PHP 使用的日期,默认TRUE。
例子1:

  1. <?php the_date(); ?>

显示格式为:2010年02月10日 (当前版本显示这个,可能会变)

例子2:

  1. <?php the_date('Y-m-d', '<h2>', '</h2>'); ?>

显示格式为:2010年02月10日 (就是用h2的格式显示)

例子3:

  1. <?php $my_date = the_date('', '', '', FALSE); echo $my_date; ?>

显示格式为:2010年02月10日

4.the_modified_time()函数
调用语句格式:

  1. <?php the_modified_time( $d ); ?>

例子1:

  1. <?php the_modified_time(); ?>

显示格式为:18:32

例子2:

  1. <?php the_modified_time('g:i a'); ?>

显示格式为:6:32 下午

例子3:

  1. <?php the_modified_time('G:i'); ?>

显示格式为:18:32

例子4:

  1. <?php the_modified_time('F j, Y'); ?>

显示格式为:二月 10, 2010

例子5:

  1. <?php the_modified_time('F j, Y'); ?> at <?php the_modified_time('g:i a'); ?>

显示格式为:二月 10, 2010 AT 6:32 下午

5.the_modified_date()函数
调用语句格式:

  1. <?php the_modified_date( $d ); ?>

例子1:

  1. <?php the_modified_date(); ?>

显示格式为:2010年02月10日

例子2:

  1. <?php the_modified_date('F j, Y'); ?>

显示格式为:二月 10, 2010

例子3:

  1. <?php the_modified_date('j\<\s\u\p\>S\<\/\s\u\p\> M Y'); ?>

显示格式为:10TH 二 2010

6.single_month_title()函数
调用语句格式:

  1. <?php single_month_title( $prefix, $display ) ?>

其中:prefix—放置在年,月前的文本
display—布尔值,是否显示,默认为TRUE
例子1:

  1. <?php single_month_title('<br />') ?>

显示格式为:
December
2004
(我的主题貌似不支持,不能显示)

例子2:

  1. <?php single_month_title('*') ?>

显示格式为:*February*2004



发表评论

(必填,但不会被公开)