概要

編輯

本模板顯示由參數值指定的時區的現在時間,由該時區的UTC offset計算出來,如果該時區當時正在實施夏令時間,也會相應調整。

注意:為減輕伺服器負荷,大多數條目頁面顯示該頁面的緩存版本,所以該版本顯示的「現在時間」可能已經過時。您可以點擊[刷新]連結來更新現在時間。

參數

編輯

{{time}} 支持兩個位置性及多個已命名參數。其中,無一為必要:

|<time zone> – 首個位置性(未命名)參數,標明模板所出示之時區的時間。倘若未填,則出示UTC時間。維基百科中,時區由其標準時間之縮寫識別。切勿使用夏令或日光節約時間之時區縮寫,否則將被略過並出現錯誤。
|<df> – 位置性(未命名)的|df=,請見
|df= – 日期格式;此參數可含多個值;除以下者,其他將被略過:
|df=dmy – 標明「日/月/年」格式;時間顯示為二十四小時格式;別稱:|df=dmy24
14:02, 8 11月 2024 MST [刷新]
|df=dmy12 – 與|df=dmy相同,惟時間為十二小時格式。
2:02 pm, 8 11月 2024 MST [刷新]
|df=mdy – 標明「月/日/,年」格式;時間顯示為二十四小時格式;若日期格式未標明,此將被應用;別稱:|df=mdy24
14:02, 11月 8, 2024 MST [刷新]
|df=mdy12 – 與|df=mdy相同,惟時間顯示為十二小時格式。
2:02 pm, 11月 8, 2024 MST [刷新]
|df=iso – 以ISO 8601格式顯示日期/時間(秒數不含於內)。
2024-11-08T14:02 MST [刷新]
|df=y – 舊版{{time}}參數,與|df=dmy相同。
|df=12 – 只顯示十二小時格式的時間。
2:02 pm MST [刷新]
|df=24 – 只顯示二十四小時格式的時間。
14:02 MST [刷新]
|df-cust= – 自定日期/時間格式,其使用於mw:Help:Extension:ParserFunctions##time界定之編碼;取決[註 1]|df=
|df-cust-a= – 如上,自定日期/時間格式,特別為上午(AM)時間;須|df-cust-p=;取決於|df-cust=
|df-cust-p= – 如上,自定日期/時間格式,特別為下午(PM)時間;須|df-cust-a=;取決於|df-cust=
|dst= – 當被設為no,該時區之日光節約時間計算將被停用;其他值會遭略過;不使用日光節約時間之地區宜用,如亞利桑那州
|lang=<code> – 以ISO 639格式,用<code>顯示日期/時間。
下列參數只可為yes
|dateonly= – 壓抑時間顯示。
|timeonly= – 壓抑日期顯示。
|hide-refresh= – 壓抑「刷新」按鈕顯示。
|hide-tz= – 壓抑時區縮寫顯示。
|unlink-tz= – 顯示非連結之時區縮寫。
|_TEST_TIME_= – 在此模板開發中卓有成效之參數。這的值須為以下其一:
無時區代號之ISO 8601格式(2024-11-08T21:02:18
以{{Timestamp}}(Template:Timestamp)產生之YYYYMMDDhhmmss格式。這會被視為UTC時間。

用法

編輯

Typically, all that is needed is:

{{time|<TZ>}} where <TZ>是支持的時區縮寫
{{time|MST}}
2024年11月8日 14:02 MST [刷新]

To change the rendered format:

{{time|MST|df=y}}
14:02, 8 11月 2024 MST [刷新]
{{time|MST|y}}
14:02, 8 11月 2024 MST [刷新]
{{time|MST|dmy}}
14:02, 8 11月 2024 MST [刷新]
{{time|MST|iso}}
2024-11-08T14:02 MST [刷新]

支持的時區

編輯

This is a list of the currently supported time zone abbreviations:

  1. ^ 1.0 1.1 1.2 Not standard time zones, these are included on a whim of the programmer; AoE is 'Anywhere on Earth', 'IDLE' and 'IDLW' are International Date Line East and West
  2. ^ Irish Standard Time. The abbreviation, IST, is also used for Indian Standard Time. Irish Standard Time occurs in the summer. For these reasons, the template uses GMT-IE as the time zone abbreviation for Ireland.
  3. ^ GMT does not observe daylight saving time. In the United Kingdom GMT is observed in winter but shifts to British Summer Time. The abbreviation BST is also used by Bangladesh Standard Time. To differentiate year-round GMT from GMT as observed in the UK, use GMT-UK.
  4. ^ Saint-Pierre and Miquelon Standard Time
  5. ^ Western Greenland Time

UTC offset

編輯

To display the time at a particular UTC offset, specify the UTC time offset as the time zone:

{{time|UTC-07:00}}
2024-11-08T14:02 UTC−07:00 [刷新]

'UTC', a sign character, two hour digits, a colon, and two minute digits are required. Accepted sign characters are: '+', '-' (hyphen), '±', and '−' (minus).

Military/nautical time zones

編輯

To display the time at a particular military or nautical time zone,[1] use the time zone's alpha designation:

{{time|M}}
2024-11-09T09:02 M [刷新]

Some military and nautical time zone designators are extended with an asterisk (*), a dagger (†), or double dagger (‡). When writing this template for designators that are extended with a dagger or double dagger, use '+' and '++' respectively:

{{time|M++}}
2024-11-09T09:47 M‡ [刷新]
{{time|M+}}
2024-11-09T11:02 M† [刷新]

夏令時間

編輯

Daylight saving time (DST) calculations are automatic for those time zones where it is observed. 有些時區在實施夏令時間時,當中若干地區不跟隨,在這些不使用夏令時間的地區可以使用|dst=no

{{time|MST|dst=no}}
2024年11月8日 14:02 MST [刷新]time in Arizona
{{time|MST}}
2024年11月8日 14:02 MST [刷新] – but, time on the Navajo Nation in Arizona

The opposite case is not supported. For places like Thule Air Base in Greenland, which observes US DST rules while WGT observes EU DST rules, a time zone properties table will be needed in Module:Time. See §Adding a new time zone.

錯誤訊息

編輯

{{time}}可以產生以下錯誤訊息,包括:

{{time}} – both of |df-cust-a= and |df-cust-p required – when defining a custom format for am (or pm) time, you must also define a custom format for pm (or am) time
{{time}} – error calculating dst timestamps – indicates an internal error because one or more of the following time zone properties is malformed: UTC offset, DST begin or end definition. To resolve this error make sure that the time zone's properties are correct.
{{time}} – incomplete definition for ... – indicates an internal error because one or more of the following time zone properties is missing: DST begin or end definition, DST event time, time zone article. To resolve this error supply the missing properties.
{{time}} – invalid date format <format> – value assigned to |df= is not one of the defined format strings; ss §Parameters
{{time}} – invalid use of ± - 符號±被用於the minute and hour offsets不是00:00的情形
{{time}} – malformed or incomplete _TEST_TIME_ – value assigned to this parameter must either have the format: YYYY-MM-DDThh:mm:ss where all except 'T' are digits, or YYYYMMDDhhmmss
{{time}} – unknown timezone – 填入的time zone positional parameter不是支持的時區縮寫。To resolve this error check the parameter's spelling or add the time zone's properties to the module. 見§加入新時區

加入新時區

編輯

{{time}}使用Module:Time/data。這是一個有多個表格的表格,the data structure that specifies the properties of the individual time zones。空白的時區properties table有以下格式:

[''] = {
	abbr = '',			
	dst_abbr = '',
	utc_offset = '',
	df = '',
	dst_begins = '',
	dst_ends = '',
	dst_time = '',
	dst_e_time = '',
	article = ''
},

在Module:Time/data加入一個新時區,add the appropriate information inside the single quotes. If a property does not apply, leave the quotes empty. The rules for each property are:

[''] – (必填)一個時區標準時間的縮寫,小寫;this is the value that will be used in the template's time zone pararameter
abbr = '' – (必填)the abbreviation of a time zone's standard time as it will be rendered by the template
dst_abbr = '' – 一個時區的夏令時間的縮寫 as it will be rendered by the template
utc_offset = '' – (必填)the offset in hours and minutes from UTC±00:00;採用以下格式:utc_offset = '<sign>hh:mm' where <sign> may be + (optional) or - (required for time zones west of the 0 meridian)
df = '' – one of three keywords dmy, mdy, or iso used to specify date format typically used in the time zone; can be overridden with |df= template parameter
dst_begins = '' – a four word sentence in the form <ordinal> <day name> <in|of> <month name> where:
<ordinal> – 'first', '1st', 'second', '2nd', ... 'fifth', '5th', 或 'last'的其中一個
<day name> – 'Sunday', 'Monday', 'Tuesday', etc.的其中一個;capitalization is not important but otherwise must be spelled correctly;不支持縮寫
<in|of> – 'in' 或 'of'的其中一個
<month name> – 月份名'January', 'February', 'March', etc.的其中一個;capitalization is not important but otherwise must be spelled correctly;不支持縮寫
dst_ends = '' – (required if dst_begins is specified) same as dst_begins
dst_time = '' – (required if dst_begins is specified) the time that daylight saving time begins; usually local time; when DST begins at a specified time UTC (European Summer Time for example) use: dst_time = 'hh:mm UTC'; four digits and the colon are required
dst_e_time = '' – the time that daylight saving time ends if different from the time it begins; usually local daylight saving time ; when DST ends at a specified time UTC use: dst_e_time = 'hh:mm UTC'; four digits and the colon are required
article = '' – (必填)該時區的條目名;do not include wikimarkup

The table-of-tables is organized east (plus UTC offsets) then west (minus UTC offset), by offset hours, and then alphabetically by time zone positional parameter name.

加入新alias

編輯

You may also want to add an alias of a timezone:

[''] = {tz = ''},

在Module:Time/data加入新時區,add the appropriate information inside the single quotes.

[''] – (required) the abbreviation of a time zone's alias. This must be lower case.
tz = '' – (required) the abbreviation of the time zone that's already in the code. This must be lower case

The table-of-tables is organized east (plus UTC offsets) then west (minus UTC offset), and by if it's a DST offset or if it's not.

See also

編輯

Template:Date and time templates

References

編輯
  1. ^ World Time Zone Map. HM Nautical Almanac Office. February 2016. 


模板編輯說明

編輯

沒有描述。

模板參數

參數描述類型狀態
time zone1

The time zone for the time formatting

範例
EST
字串建議
date format2 df

The format to render the date and time

範例
dmy12
不明建議
Daylight savings timedst

沒有描述

範例
yes
字串非必填
ISO 639 language codelang

displays time/date in language specified by ISO 639 language

字串非必填
dateonlydateonly

If 'yes', suppresses display of the time and only shows the date

範例
yes
字串非必填
timeonlytimeonly

If 'yes', suppresses display of the date and only shows the time

範例
yes
字串非必填
Hide time zone?hide-tz

If 'yes', suppresses time zone abbreviation

範例
yes
字串非必填
Don't link time zone?unlink-tz

If 'yes', renders the timezone without linking to its article.

範例
yes
字串非必填

參見

編輯


引用錯誤:頁面中存在<ref group="註">標籤,但沒有找到相應的<references group="註" />標籤