mw:Help:ParserFunctions##time

This parser function takes a date and/or time (default: the current date and time), and optionally performs additions and subtractions, and returns the result (or selected parts from it) in a specified format.

Time

edit

The date/time object can be in any format accepted by PHP's strtotime() function.

  • {{#time:j F Y, G:i:s|now}} → 4 December 2024, 15:04:34 [1]
  • {{#time:j F Y, G:i:s|9 June 2010 7:34 120 hours 241 hours}} → 24 June 2010, 8:34:00 [2]
  • {{#time:j F Y, G:i:s|240 hours -120 hours}} → 9 December 2024, 15:04:34 [3]

The range of acceptable input is 1 January 0100 → 31 December 9999. Years in the range 1970-2069 can be abbreviated to two digits. Even with leading zeros they are interpreted as years in the mentioned range.

  • {{#time:j F Y, G:i:s|15 April 0069}} → 15 April 0069, 0:00:00 [4]
  • {{#time:j F Y, G:i:s|15 April 0070}} → 15 April 0070, 0:00:00 [5]
  • {{#time:j F Y, G:i:s|15 April 10000}}Error: Invalid time. [6]

Full or partial absolute dates can be specified; the function will fill in parts of the date that are not specified using the current values. However, the fill-in feature is not consistent; some parts are filled in using the current values, others are not:

  • {{#time:j F Y, G:i:s|240809}} → 5 December 2024, 0:08:09 [7]
  • {{#time:j F Y, G:i:s|076009}}Error: Invalid time. [8]
  • {{#time:j F Y, G:i:s|070860}} → 4 December 2024, 7:09:00 [9]
  • {{#time:j F Y, G:i:s|10203}}Error: Invalid time. [10]
  • {{#time:j F Y, G:i:s|0809}} → 4 December 0809, 0:00:00 [11]
  • {{#time:j F Y, G:i:s|2409}} → 4 December 2409, 0:00:00 [12]
  • {{#time:j F Y, G:i:s|0860}} → 4 December 0860, 0:00:00 [13]
  • {{#time:j F Y, G:i:s|708}}Error: Invalid time. [14]
  • {{#time:j F Y, G:i:s|07}}Error: Invalid time. [15]
  • {{#time:j F Y, G:i:s|jun}} → 4 June 2024, 0:00:00 [16]
  • {{#time:j F Y, G:i:s|jun2}} → 2 June 2024, 0:00:00 [17]
  • {{#time:j F Y, G:i:s|jun22}} → 22 June 2024, 0:00:00 [18]
  • {{#time:j F Y, G:i:s|jun222}}Error: Invalid time. [19]
  • {{#time:j F Y, G:i:s|jun}} → 4 June 2024, 0:00:00 [20]
  • {{#time:j F Y, G:i:s|jun}} → 4 June 2024, 0:00:00 [21]
  • {{#time:j F Y, G:i:s|jun}} → 4 June 2024, 0:00:00 [22]
  • {{#time:j F Y, G:i:s|jun}} → 4 June 2024, 0:00:00 [23]
  • {{#time:j F Y, G:i:s|jun}} → 4 June 2024, 0:00:00 [24]
  • {{#time:j F Y, G:i:s|7}}Error: Invalid time. [25]
  • {{#time:j F Y, G:i:s|7}}Error: Invalid time. [26]
  • {{#time:j F Y, G:i:s|8 June 2009 7:34}} → 8 June 2009, 7:34:00 [27]
  • {{#time:j F Y, G:i:s|June 2009 7:34}} → 1 June 2009, 7:34:00 [28]
  • {{#time:j F Y, G:i:s|8 2009 7:34}}Error: Invalid time. [29]
  • {{#time:j F Y, G:i:s|8 June 7:34}}Error: Invalid time. [30]
  • {{#time:j F Y, G:i:s|8 June 2009}} → 8 June 2009, 0:00:00 [31]
  • {{#time:j F Y, G:i:s|June 2009}} → 1 June 2009, 0:00:00 [32]
  • {{#time:j F Y, G:i:s|8 June}} → 8 June 2024, 0:00:00 [33]
  • {{#time:j F Y, G:i:s|8 2009}}Error: Invalid time. [34]
  • {{#time:j F Y, G:i:s|2009 7:34}}Error: Invalid time. [35]
  • {{#time:j F Y, G:i:s|June 7:34}} → 4 June 2024, 7:34:00 [36]
  • {{#time:j F Y, G:i:s|8 7:34}}Error: Invalid time. [37]
  • {{#time:j F Y, G:i:s|9}}Error: Invalid time. [38]
  • {{#time:j F Y, G:i:s|June}} → 4 June 2024, 0:00:00 [39]
  • {{#time:j F Y, G:i:s|2009}} → 4 December 2009, 0:00:00 [40]
  • {{#time:j F Y, G:i:s|7:34}} → 4 December 2024, 7:34:00 [41]
  • {{#time:j F Y, G:i:s|08 June 2009 7:34}} → 8 June 2009, 7:34:00 [42]
  • {{#time:j F Y, G:i:s|June 2009 7:34}} → 1 June 2009, 7:34:00 [43]
  • {{#time:j F Y, G:i:s|08 2009 7:34}}Error: Invalid time. [44]
  • {{#time:j F Y, G:i:s|08 June 7:34}}Error: Invalid time. [45]
  • {{#time:j F Y, G:i:s|08 June 2009}} → 8 June 2009, 0:00:00 [46]
  • {{#time:j F Y, G:i:s|June 2009}} → 1 June 2009, 0:00:00 [47]
  • {{#time:j F Y, G:i:s|08 June}} → 8 June 2024, 0:00:00 [48]
  • {{#time:j F Y, G:i:s|08 2009}}Error: Invalid time. [49]
  • {{#time:j F Y, G:i:s|2009 7:34}}Error: Invalid time. [50]
  • {{#time:j F Y, G:i:s|June 7:34}} → 4 June 2024, 7:34:00 [51]
  • {{#time:j F Y, G:i:s|08 7:34}}Error: Invalid time. [52]
  • {{#time:j F Y, G:i:s|09}}Error: Invalid time. [53]
  • {{#time:j F Y, G:i:s|June}} → 4 June 2024, 0:00:00 [54]
  • {{#time:j F Y, G:i:s|2009}} → 4 December 2009, 0:00:00 [55]
  • {{#time:j F Y, G:i:s|7:34}} → 4 December 2024, 7:34:00 [56]
  • {{#time:j F Y, G:i:s|8 June 2009 734}}Error: Invalid time. [57]
  • {{#time:j F Y, G:i:s|June 2009 734}}Error: Invalid time. [58]
  • {{#time:j F Y, G:i:s|8 2009 734}}Error: Invalid time. [59]
  • {{#time:j F Y, G:i:s|8 June 734}} → 8 June 0734, 0:00:00 [60]
  • {{#time:j F Y, G:i:s|8 June 2009}} → 8 June 2009, 0:00:00 [61]
  • {{#time:j F Y, G:i:s|June 2009}} → 1 June 2009, 0:00:00 [62]
  • {{#time:j F Y, G:i:s|8 June}} → 8 June 2024, 0:00:00 [63]
  • {{#time:j F Y, G:i:s|8 2009}}Error: Invalid time. [64]
  • {{#time:j F Y, G:i:s|2009 734}}Error: Invalid time. [65]
  • {{#time:j F Y, G:i:s|June 734}}Error: Invalid time. [66] ("June 73", 2004)
  • {{#time:j F Y, G:i:s|8 734}}Error: Invalid time. [67]
  • {{#time:j F Y, G:i:s|9}}Error: Invalid time. [68]
  • {{#time:j F Y, G:i:s|June}} → 4 June 2024, 0:00:00 [69]
  • {{#time:j F Y, G:i:s|2009}} → 4 December 2009, 0:00:00 [70]
  • {{#time:j F Y, G:i:s|734}}Error: Invalid time. [71]
  • {{#time:j F Y, G:i:s|08 June 2009 734}}Error: Invalid time. [72]
  • {{#time:j F Y, G:i:s|June 2009 734}}Error: Invalid time. [73]
  • {{#time:j F Y, G:i:s|08 2009 734}}Error: Invalid time. [74]
  • {{#time:j F Y, G:i:s|08 June 734}} → 8 June 0734, 0:00:00 [75]
  • {{#time:j F Y, G:i:s|08 June 2009}} → 8 June 2009, 0:00:00 [76]
  • {{#time:j F Y, G:i:s|June 2009}} → 1 June 2009, 0:00:00 [77]
  • {{#time:j F Y, G:i:s|08 June}} → 8 June 2024, 0:00:00 [78]
  • {{#time:j F Y, G:i:s|08 2009}}Error: Invalid time. [79]
  • {{#time:j F Y, G:i:s|2009 734}}Error: Invalid time. [80]
  • {{#time:j F Y, G:i:s|June 734}}Error: Invalid time. [81]
  • {{#time:j F Y, G:i:s|08 734}}Error: Invalid time. [82]
  • {{#time:j F Y, G:i:s|09}}Error: Invalid time. [83]
  • {{#time:j F Y, G:i:s|June}} → 4 June 2024, 0:00:00 [84]
  • {{#time:j F Y, G:i:s|2009}} → 4 December 2009, 0:00:00 [85]
  • {{#time:j F Y, G:i:s|734}}Error: Invalid time. [86]
  • {{#time:j F Y, G:i:s|9 June 2010 :34}}Error: Invalid time. [87]
  • {{#time:j F Y, G:i:s|9 June 2010 7}}Error: Invalid time. [88]


  • {{#time:j F Y, G:i:s|January 1}} → 1 January 2024, 0:00:00 [89]
  • {{#time:j F Y, G:i:s|February 2007}} → 1 February 2007, 0:00:00 [90] Goes to the start of the month, not the current day.

A four-digit number is interpreted as hours and minutes if possible, and otherwise as year:

  • {{#time:j F Y, G:i:s|1959}} → 4 December 1959, 0:00:00 [91]
  • {{#time:j F Y, G:i:s|1960}} → 4 December 1960, 0:00:00 [92]

A six-digit number is interpreted as hours, minutes and seconds if possible, but otherwise as an error (not, for instance, a year and month):

  • {{#time:j F Y, G:i:s|195909}} → 4 December 2024, 19:59:09 [93]
  • {{#time:j F Y, G:i:s|196009}}Error: Invalid time. [94]

Unix timestamp: pre-pend an @ symbol:

  • {{#time:j F Y, G:i:s|@1733324677}} → 4 December 2024, 15:04:37 [95]

Year

edit
  • {{#time:j F Y, G:i:s U|100}}Error: Invalid time. [96]
  • {{#time:j F Y, G:i:s U|101}}Error: Invalid time. [97]
  • {{#time:j F Y, G:i:s U|160}}Error: Invalid time. [98]
  • {{#time:j F Y, G:i:s U|260}}Error: Invalid time. [99]
  • {{#time:j F Y, G:i:s U|360}}Error: Invalid time. [100]
  • {{#time:j F Y, G:i:s U|460}}Error: Invalid time. [101]
  • {{#time:j F Y, G:i:s U|560}}Error: Invalid time. [102]
  • {{#time:j F Y, G:i:s U|660}}Error: Invalid time. [103]
  • {{#time:j F Y, G:i:s U|760}}Error: Invalid time. [104]
  • {{#time:j F Y, G:i:s U|860}}Error: Invalid time. [105]
  • {{#time:j F Y, G:i:s U|960}}Error: Invalid time. [106]
  • {{#time:j F Y, G:i:s U|1060}} → 4 December 1060, 0:00:00 -28687651200 [107]
  • {{#time:j F Y, G:i:s U|1160}} → 4 December 1160, 0:00:00 -25531977600 [108]
  • {{#time:j F Y, G:i:s U|1260}} → 4 December 1260, 0:00:00 -22376217600 [109]
  • {{#time:j F Y, G:i:s U|1360}} → 4 December 1360, 0:00:00 -19220544000 [110]
  • {{#time:j F Y, G:i:s U|1460}} → 4 December 1460, 0:00:00 -16064870400 [111]
  • {{#time:j F Y, G:i:s U|1560}} → 4 December 1560, 0:00:00 -12909196800 [112]
  • {{#time:j F Y, G:i:s U|1660}} → 4 December 1660, 0:00:00 -9753436800 [113]
  • {{#time:j F Y, G:i:s U|1760}} → 4 December 1760, 0:00:00 -6597763200 [114]
  • {{#time:j F Y, G:i:s U|1860}} → 4 December 1860, 0:00:00 -3442089600 [115]
  • {{#time:j F Y, G:i:s U|1960}} → 4 December 1960, 0:00:00 -286416000 [116]
  • {{#time:j F Y, G:i:s U|16}}Error: Invalid time. [117]
  • {{#time:j F Y, G:i:s U|60}}Error: Invalid time. [118]
  • {{#time:j F Y, G:i:s U|99}}Error: Invalid time. [119]
  • {{#time:j F Y, G:i:s U|1999}} → 4 December 1999, 0:00:00 944265600 [120]
  • {{#time:j F Y, G:i:s U|2400}} → 4 December 2400, 0:00:00 13598668800 [121]
  • {{#time:j F Y, G:i:s U|9999}} → 4 December 9999, 0:00:00 253399881600 [122]

Year and month

edit
  • {{#time:j F Y, G:i:s U|jun8}} → 8 June 2024, 0:00:00 1717804800 [123]

Month

edit
  • {{#time:j F Y, G:i:s U|jun}} → 4 June 2024, 0:00:00 1717459200 [124]

Year, month and day

edit
  • {{#time:j F Y, G:i:s U|1-2-3}} → 3 February 2001, 0:00:00 981158400 [125]
  • {{#time:j F Y, G:i:s U|1-2-2003}} → 1 February 2003, 0:00:00 1044057600 [126]
  • {{#time:j F Y, G:i:s U|1/2/3}} → 2 January 2003, 0:00:00 1041465600 [127]
  • {{#time:j F Y, G:i:s U|2008/2/3}} → 3 February 2008, 0:00:00 1201996800 [128]
  • Expression error: Unrecognized word "january".

Output selection and format

edit

Characters in the formatting string that are not recognised (including spaces, link brackets, and formatting apostrophs) are passed through unaltered. There are also two ways to escape characters within the formatting string:

  1. A backslash followed by a formatting character is interpreted as a single literal character
  2. characters enclosed in double quotes are considered literal characters, and the quotes are removed

In addition, the digraph xx is interpreted as a single literal "x". However, in view of the limitation that the total length of the format strings of the expanded calls of #time is limited to 6000 characters [129], it can be useful to avoid literal characters (even spaces), and use multiple calls instead. For example, instead of {{#time:d F Y|20100912123456}} one can use {{#time:d|20100912123456}} {{#time:F|20100912123456}} {{#time:Y|20100912123456}}. If the argument is the result of some expansion, multiple counts for that are avoided with a template containing e.g. {{#time:d|{{{1}}}}} {{#time:F|{{{1}}}}} {{#time:Y|{{{1}}}}}. This reduces the time-format count from 5 to 3, and if a similar template is used for e.g. F Y then this may give even further reduction due to additional reuse: once d F Y and once F Y reduces the count from from 8 to 4.

Code Description Current output
Year
Y 4-digit year. 2024
y 2-digit year. 24
L 1 or 0 whether it's a leap year or not 1
o ¹ ISO-8601 year number. ² 2024 ³

¹ Requires PHP 5.1.0 and newer and rev:45208
² This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead.
³ Will output literal o if ¹ not fulfilled

Month
n Month index, not zero-padded. 12
m Month index, zero-padded. 12
M An abbreviation of the month name, in the site language. Dec
F The full month name in the site language. December
Week
W ISO 8601 week number, zero-padded. 49
Day
j Day of the month, not zero-padded. 4
d Day of the month, zero-padded. 04
z Day of the year (January 1 = 0)
[[#ref_{{{1}}}|^]]  To get the ISO day of the year add 1.
338
D An abbreviation for the day of the week. Rarely internationalised. Wed
l The full weekday name. Rarely internationalised. Wednesday
N ISO 8601 day of the week (Monday = 1, Sunday = 7). 3
w number of the day of the week (Sunday = 0, Saturday = 6). 3
Hour
a "am" during the morning (00:00:00 → 11:59:59), "pm" otherwise (12:00:00 → 23:59:59) pm
A Uppercase version of a above. PM
g Hour in 12-hour format, not zero-padded. 3
h Hour in 12-hour format, zero-padded. 03
G Hour in 24-hour format, not zero-padded. 15
H Hour in 24-hour format, zero-padded. 15
Minutes and seconds
i Minutes past the hour, zero-padded. 04
s Seconds past the minute, zero-padded. 37
U Seconds since January 1 1970 00:00:00 GMT. 1733324677
Miscellaneous
L 1 if this year is a leap year in the Gregorian calendar, 0 otherwise 1
t Number of days in the current month. 31
c ISO 8601 formatted date, equivalent to Y-m-dTH:i:s+00:00. 2024-12-04T15:04:37+00:00
r RFC 2822 formatted date, equivalent to D, j M Y H:i:s +0000, with weekday name and month name not internationalised. Wed, 04 Dec 2024 15:04:37 +0000

Foreign

edit
Code Description Current output
xg Output the full month name in the genitive form for site languages that distinguish between genitive and nominative forms. For Polish:

(nominative)

{{#time:d F Y|20 June 2010}} → 20 czerwiec 2010

(genitive)

{{#time:d xg Y|20 June 2010}} → 20 czerwca 2010

Non-Gregorian calendars
Iranian
xij Day of the month 14
xiF Full month name Azar
xin Month index 9
xiY Full year 1403
Hebrew
xjj Day of the month 3
xjF Full month name Kislev
xjx Genitive form of the month name Kislev
xjn Month number 3
xjY Full year 5785
Thai solar
xkY Full year 2567
Flags
xn Format the next numeric code as a raw ASCII number. In the Hindi language, {{#time:H, xnH}} produces ०६, 06
xN Like xn, but as a toggled flag, which endures until the end of the string or until the next appearance of xN in the string.
xr Format the next number as a roman numeral. Only works for numbers up to 3000. {{#time:xrY}} → MMXXIV