WordPress: Formatting Date and Time:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: ==Customizing the Time and Date== Certain WordPress tag functions are used to display or return date and time information; the_date() and [[WordPres...)
 
无编辑摘要
第1行: 第1行:
==Customizing the Time and Date==
==Customizing the Time and Date==


Certain WordPress tag functions are used to display or return date and time information; [[WordPress:Template Tags/the date|the_date()]] and [[WordPress:Template Tags/the time|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.
Certain WordPress tag functions are used to display or return date and time information; [[WordPress:Template Tags/the date|the_date()]] and [[WordPress:Template Tags/the time|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.
==定义时间和日期==
特定的WordPress标签功能用来显示或者返回日期和时间信息;[[WordPress:Template Tags/the date|the_date()]]和[[WordPress:Template Tags/the time|the_time()]]就是例子。这些功能中的一些接受一个叫做format string的参数,允许你确定如何显示日期。format string是一个日期的多个部分组合(使用 "format characters")起来按照指定的格式生成日期的模板。


For example, the format string:
For example, the format string:
第11行: 第14行:


  Friday, September 24, 2004
  Friday, September 24, 2004
例如format string如下:
l, F j, Y
建立的日期显示如下:
Friday, September 24, 2004


Here is what each format character in the string above represents:  
Here is what each format character in the string above represents:  
第19行: 第30行:
* <code>Y</code> = The year in 4 digits. (lower-case y gives the year's last 2 digits)
* <code>Y</code> = The year in 4 digits. (lower-case y gives the year's last 2 digits)
: (Commas are read literally.)
: (Commas are read literally.)
这里是上边字符串中每个format character的显示结果:
* <code>l</code> = 星期几的全写(小写字母L).
* <code>F</code> =月的全写.
* <code>j</code> = 日.
* <code>Y</code> = 四位数字显示的年. (小写的y 显示年的最后两位)
: (逗号起分隔作用.)


WordPress is written in the programming language [[WordPress:Glossary#PHP|PHP]].  The date formatting functions in WordPress use PHP's built-in date formatting functions. Therefore, you can use the [http://php.net/date table of date format characters on the PHP website] as a reference for building date format strings for use in WordPress.
WordPress is written in the programming language [[WordPress:Glossary#PHP|PHP]].  The date formatting functions in WordPress use PHP's built-in date formatting functions. Therefore, you can use the [http://php.net/date table of date format characters on the PHP website] as a reference for building date format strings for use in WordPress.
WordPress是使用[[WordPress:Glossary#PHP|PHP]]代码编写的。WordPress中的日期是使用PHP的内建日期格式化功能实现的。这样,你可以使用[http://php.net/date PHP网页上日期format characters表格]作为WordPress中建立日期format strings时的参考。


<p class="postmetadata alt"><small>This entry was posted  
<p class="postmetadata alt"><small>This entry was posted  
第33行: 第54行:
* [[WordPress:Plugins/Calendar_Event|Calendar and Event Plugins]]
* [[WordPress:Plugins/Calendar_Event|Calendar and Event Plugins]]
* [[WordPress:Plugins/Time|Time oriented Plugins]]
* [[WordPress:Plugins/Time|Time oriented Plugins]]
===时间,日历和时间插件===
* [[WordPress:Plugins/Calendar_Event|日期和时间插件]]
* [[WordPress:Plugins/Time|时间向导插件]]

2008年4月15日 (二) 11:40的版本

Customizing the Time and Date

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.

定义时间和日期

特定的WordPress标签功能用来显示或者返回日期和时间信息;the_date()the_time()就是例子。这些功能中的一些接受一个叫做format string的参数,允许你确定如何显示日期。format string是一个日期的多个部分组合(使用 "format characters")起来按照指定的格式生成日期的模板。

For example, the format string:

l, F j, Y

creates a date that look like this:

Friday, September 24, 2004

例如format string如下:

l, F j, Y

建立的日期显示如下:

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.)

这里是上边字符串中每个format character的显示结果:

  • l = 星期几的全写(小写字母L).
  • F =月的全写.
  • j = 日.
  • Y = 四位数字显示的年. (小写的y 显示年的最后两位)
(逗号起分隔作用.)

WordPress is written in the programming language PHP. The date formatting functions in WordPress use PHP's built-in date formatting functions. Therefore, 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.

WordPress是使用PHP代码编写的。WordPress中的日期是使用PHP的内建日期格式化功能实现的。这样,你可以使用PHP网页上日期format characters表格作为WordPress中建立日期format strings时的参考。

Event, Calendar, and Time Plugins

时间,日历和时间插件