跳转到内容

模板:Time/doc

本页使用了标题或全文手工转换
维基百科,自由的百科全书

概要

本模板显示由参数值指定的时区的现在时间,由该时区的UTC offset计算出来,如果该时区当时正在实施夏令时间,也会相应调整。

注意:为减轻服务器负荷,大多数条目页面显示该页面的缓存版本,所以该版本显示的“现在时间”可能已经过时。您可以点击[刷新]链接来更新现在时间。

参数

{{time}} 支持两个位置性及多个已命名参数。其中,无一为必要:

|<time zone> – 首个位置性(未命名)参数,标明模板所出示之时区的时间。倘若未填,则出示UTC时间。维基百科中,时区由其标准时间之缩写识别。切勿使用夏令或日光节约时间之时区缩写,否则将被略过并出现错误。
|<df> – 位置性(未命名)的|df=,请见
|df= – 日期格式;此参数可含多个值;除以下者,其他将被略过:
|df=dmy – 标明“日/月/年”格式;时间显示为二十四小时格式;别称:|df=dmy24
23:22, 8 11月 2024 MST [刷新]
|df=dmy12 – 与|df=dmy相同,惟时间为十二小时格式。
11:22 pm, 8 11月 2024 MST [刷新]
|df=mdy – 标明“月/日/,年”格式;时间显示为二十四小时格式;若日期格式未标明,此将被应用;别称:|df=mdy24
23:22, 11月 8, 2024 MST [刷新]
|df=mdy12 – 与|df=mdy相同,惟时间显示为十二小时格式。
11:22 pm, 11月 8, 2024 MST [刷新]
|df=iso – 以ISO 8601格式显示日期/时间(秒数不含于内)。
2024-11-08T23:22 MST [刷新]
|df=y – 旧版{{time}}参数,与|df=dmy相同。
|df=12 – 只显示十二小时格式的时间。
11:22 pm MST [刷新]
|df=24 – 只显示二十四小时格式的时间。
23:22 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-09T06:22:05
以{{Timestamp}}(Template:Timestamp)产生之YYYYMMDDhhmmss格式。这会被视为UTC时间。

用法

Typically, all that is needed is:

{{time|<TZ>}} where <TZ>是支持的时区缩写
{{time|MST}}
2024年11月8日 23:22 MST [刷新]

To change the rendered format:

{{time|MST|df=y}}
23:22, 8 11月 2024 MST [刷新]
{{time|MST|y}}
23:22, 8 11月 2024 MST [刷新]
{{time|MST|dmy}}
23:22, 8 11月 2024 MST [刷新]
{{time|MST|iso}}
2024-11-08T23:22 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-08T23:22 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-09T18:22 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-09T19:07 M‡ [刷新]
{{time|M+}}
2024-11-09T20:22 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日 23:22 MST [刷新]time in Arizona
{{time|MST}}
2024年11月8日 23:22 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="註" />标签