模板:Format date

維基百科,自由的百科全書
文件圖示 模板文件[檢視] [編輯] [歷史] [清除快取]

Usage[編輯]

This template ({{Format date}}) returns a date, or date-time, without the hidden version for use in microformats. This template is probably best used internally in other templates.

If you need the microformat support, use template {{Start date}} instead.

If you want sortable dates for a table, use {{Dts}} instead.

Syntax[編輯]

  • {{Format date|year|month|day}}
  • {{Format date|year|month|day|HH|MM|SS|TimeZone}} (MM and SS are optional; TimeZone may be a numerical value, or "Z" for UTC; see examples)

Examples:

  • {{Format date|1993}} returns "1993"
  • {{Format date|1993|02}} returns "1993年2月"
  • {{Format date|1993|02|24}} returns "1993年2月24日"
  • {{Format date|1993|02|24|08|30}} returns "08:30, 1993年2月24日"
  • {{Format date|1993|02|24|08|||+01:00}} returns "1993年2月24日 (+01:00)"
  • {{Format date|1993|02|24|08|||-07:00}} returns "1993年2月24日 (-07:00)"
    {{Format date|1993|02|24|08|30|23}} returns "08:30:23, 1993年2月24日"
  • {{Format date|1993|02|24|08|30|23|Z}} returns "08:30:23, 1993年2月24日 (UTC)"
  • {{Format date|1993|02|24|08|30|23|+01:00}} returns "08:30:23, 1993年2月24日 (+01:00)"
  • {{Format date|1993|02|24|08|30|23|-07:00}} returns "08:30:23, 1993年2月24日 (-07:00)"

An optional parameter, df, can be set to "y" or "yes" (or indeed any value) to display the day before the month. This is primarily used in articles about events in parts of the world where the day precedes the month in a date.

Examples:

  • {{Format date|1993|02|24|df=y}} returns "表達式錯誤:無法識別標點符號「日」。 2月"
  • {{Format date|1993|02|24|08|30|df=yes}} returns "08:30, 表達式錯誤:無法識別標點符號「日」。 2月"

Note: The template will appear broken when the parameters are left blank (as seen hereinbefore).

參見[編輯]

  • {{Date}} (an alternative to this template, using a different syntax)
  • {{Start date}} (using the same syntax, but with the support for microformats)
  • {{Start-date}} (an alternative to the template {{Start date}})
  • {{Format time}} for formatting times only