defzone.net@gmail.comLiên hệ
DZ
DefZone.Net

Kien thuc cong nghe & giai tri

Bai vietDia diemAlbum anhGameCua hang
  1. Home
  2. Wiki


Template documentation[view] [edit] [history] [purge]
For the article header for year articles, see Template:Year article header.
WarningThis template is used on approximately 104,000 pages.
To avoid major disruption and server load, any changes should be tested in the template's /sandbox or /testcases subpages, or in your own user subpage. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them.

Usage

[edit]

{{YEAR|string formatted as a valid date}}

Specify optional parameter {{{2}}} to get soft error rather than a hard {{error}}

  • {{YEAR|1999}} gives: 1999
  • {{YEAR|1999-12-12}} gives: 1999
  • {{YEAR|January 1999}} gives: 1999
  • {{YEAR|1 January 1999}} gives: 1999
  • {{YEAR|January 1, 1999}} gives: 1999
  • {{YEAR|1-2-1990}} gives: 1990
  • {{YEAR|1/2/1990}} gives: 1990
  • {{YEAR|2239-10-23}} gives: 2239

Reports "Error" if given bad input:

  • {{YEAR|1-14-1990}} gives: Error
         Reason for the error: there are not 14 months.
  • {{YEAR|61 January 1999}} gives: Error
         Reason for the error: no month has 61 days.
  • {{YEAR|1 MyMonth 1999}} gives: Error
         Reason for the error: there is no such month name.
  • {{YEAR|some text which is not a date}} gives: Error
         Reason for the error: no date information to parse.
  • {{YEAR|on approximately 1999-12-12}} gives: Error
         Reason for the error: includes extraneous content.

If used with a year range, it returns only the first match:

  • {{YEAR|1999-2001}} gives: 1999

This presently only works when the year range is specified with a hyphen; if correctly given with an en dash, it reports an error (this will probably not be fixed, because handling ranges is not the template's function; that it kinda-sorta works on something like 1999-2001 with a hyphen is basically just an accident):

  • {{YEAR|1999–2001}} gives: Error

If used without input, it simply outputs the current year:

  • {{YEAR}} gives: 2025

It can be cleanly substituted for this purpose. If fed invalid data when substituted, it produces a larger, red error.

See also

[edit]
  • {{date}} – outputs the current date in various parameter-controlled formats
  • {{DATE}} – a subst-only convenience template used inside cleanup/dispute templates; {{subst:DATE}} produces: date=December 2025
  • Category:Time, date and calendar templates – numerous date computing, formatting, annotating, and navigation templates
The above documentation is transcluded from Template:YEAR/doc. (edit | history)
Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages.
Add categories to the /doc subpage. Subpages of this template.


DZ
DefZone.Net

Noi chia se kien thuc, huong dan va kham pha cong nghe.

Lien ket nhanh

Trang chủBài viếtWikiCửa hàngLiên hệ

Liên hệ

Email: defzone.net@gmail.com
Điện thoại: +84 762 559 696
Địa chỉ: Thiên Hương, Thủy Nguyên, Hải Phòng

Đăng ký nhận tin

Nhận bài viết và cập nhật mới nhất qua email.

© 2025 DefZone.Net. All rights reserved.
PrivacyTermsSitemap