Help:Time function
This help page is a how-to guide. It details processes or procedures of some aspect(s) of Wikipedia's norms and practices. It is not one of Wikipedia's policies or guidelines, and may reflect varying levels of consensus and vetting.  | 
The time function, or #time, is the MediaWiki parser function to display a date/time in other formats. For example ( to update):
- {{#time:j F Y}} shows: 4 November 2025, the current UTC date
 - {{#time:F j, Y}} shows: November 4, 2025, the current date in mdy format
 - {{#time:Y-m-d}} shows: 2025-11-04, current ISO 8601 date
 - {{#time:H:i:s}} shows: 01:22:38, current time-of-day
 - {{#time:l}} shows "Tuesday" as current day of week
 - {{#time:\d\a\y D}} shows "day Tue" as current 3-letter day
 - {{#time:j. F Y|7 May 2013|de}} shows "7. Mai 2013" as a date in German
 - {{#time:xij xiF xiY}} shows "13 Aban 1404" as current date in Iranian calendar
 
There are over 35 date format codes (see below: Time format codes) to rearrange the day-month-year, or hour-minute-second (such as 'j' for day, 'H' for hour, or el 'l' to show day-of-week). Other letters are treated as literal text, or use backslash to escape the format ('\d' shows 'd'). Parameter 2 can designate some other date/time (in any of several typical formats), while a 2-letter language code can be specified as parameter 3 to translate a month name into another language.
Beyond the Gregorian calendar, the #time function can also convert a date into some other calendars by using x-codes (x_): Islamic (xm), Iranian (xi), Hebrew (xj), Thai (xk), Minguo (xo), or the Japanese calendar (xt). For example, to show the Islamic date, as the month and year: {{#time:xmF xmY}} → Jumada al-awwal 1447.
The #time function can show numerals in some other number systems by using x-codes (x_), including: Hindi (xn or xN), Hebrew (xh), and Roman numerals (xr). For example, to show the current time, H:i:s, in Roman numerals: {{#time:xrH:xri:xrs}} → I:XXII:XXXVIII. See more examples below: Time format codes.
General features
The #time parser function takes a date and/or time (in the Gregorian calendar) and formats it according to the syntax given. A date/time object can be specified; the default is the value of the magic word {{CURRENTTIMESTAMP}} – that is, the time the page was last rendered into HTML.
- {{#time: format string }}
 - {{#time: format string | date/time object }}
 - {{#time: format string | date/time object | language code }}
 
The list of accepted formatting codes is given in the table below. Any character in the formatting string that is not recognised is passed through unaltered; this applies also to blank spaces (the system does not need them for interpreting the codes). There are also two ways to escape characters within the formatting string:
- A backslash followed by a formatting character is interpreted as a single literal character
 - 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".
- {{#time: Y-m-d }} → 2025-11-04
 - {{#time: [[Y]] m d }} → 2025 11 04
 - {{#time: [[Y (year)]] }} → 2025 (25UTCamTue, 04 Nov 2025 01:22:38 +0000)
 - {{#time: [[Y "(year)"]] }} → 2025 (year)
 - {{#time: i's" }} → 22'38"
 
The date/time object can be in any format accepted by PHP's strtotime() function. Both absolute (e.g., 20 December 2000) and relative (e.g., +20 hours) times are accepted.
- {{#time: r|now}} → Tue, 04 Nov 2025 01:22:38 +0000
 - {{#time: r|+2 hours}} → Tue, 04 Nov 2025 03:22:38 +0000
 - {{#time: r|now + 2 hours}} → Tue, 04 Nov 2025 03:22:38 +0000
 - {{#time: r|20 December 2000}} → Wed, 20 Dec 2000 00:00:00 +0000
 - {{#time: r|December 20, 2000}} → Wed, 20 Dec 2000 00:00:00 +0000
 - {{#time: r|2000-12-20}} → Wed, 20 Dec 2000 00:00:00 +0000
 - {{#time: r|2000 December 20}} → Error: Invalid time.
 
The two-letter language code in ISO 639-1 allows the string to be displayed in the chosen language.
- {{#time:d F Y|1988-02-28|nl}} → 28 februari 1988
 - {{#time:l|now|uk}} → вівторок
 - {{#time:d xg Y|20 June 2010|pl}} → 20 czerwca 2010
 
If you've calculated a Unix timestamp, you may use it in date calculations by pre-pending an @ symbol.
- {{#time: U | now }} → 1762219358
 - {{#time: r|@1762219358}} → Tue, 04 Nov 2025 01:22:38 +0000
 
| The range of acceptable input is 1 January 0111 → 31 December 9999. For the years 100 through 110 the output is inconsistent, Y and leap years are like the years 100-110, r, D, l and U are like interpreting these years as 2000-2010. {{#time: d F Y | 29 Feb 0100 }} → 01 March 0100 (correct, no leap year), but Year numbers 0-99 are interpreted as 2000-2069 and 1970-1999, even when written with leading zeros: 
  | 
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:
- {{#time: Y | January 1 }} → 2025
 
Many options are provided.
Time format codes
The following table explains the 35 various codes for date/time formats, plus the codes for months in other languages, and the x-codes (x_) to convert to some other calendars or number systems.
| Code | Description | Current output  (Purge this page's cache to update)  | 
|---|---|---|
| Year | ||
| Y | 4-digit year. | 2025 | 
| y | 2-digit year. | 25 | 
| L | 1 if it's a leap year, 0 if not. | 0 | 
| o ¹ | ISO-8601 year of the specified week. ² | 2025 ³ | 
| 
 ¹ Requires PHP 5.1.0 and newer and rev:45208.  | ||
| Month | ||
| n | Month index, not zero-padded. | 11 | 
| m | Month index, zero-padded. | 11 | 
| M | An abbreviation of the month name, in the site language. | Nov | 
| F | The full month name in the site language. | November | 
| 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|pl}} → 20 czerwiec 2010 (genitive) {{#time:d xg Y|20 June 2010|pl}} → 20 czerwca 2010  | 
| Week | ||
| W | ISO 8601 week number, zero-padded. | 45 | 
| 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).¹ | 307 | 
| D | An abbreviation for the day of the week. Rarely internationalised. | Tue | 
| l | The full weekday name. Rarely internationalised. | Tuesday | 
| N | ISO 8601 day of the week (Monday = 1, Sunday = 7). | 2 | 
| w | Number of the day of the week (Sunday = 0, Saturday = 6). | 2 | 
| 
 ¹ To get the ISO day of the year add 1.  | ||
| Hour | ||
| a | "am" during the morning (00:00:00 → 11:59:59), "pm" otherwise (12:00:00 → 23:59:59). | am | 
| A | Uppercase version of a above. | AM | 
| g | Hour in 12-hour format, not zero-padded. | 1 | 
| h | Hour in 12-hour format, zero-padded. | 01 | 
| G | Hour in 24-hour format, not zero-padded. | 1 | 
| H | Hour in 24-hour format, zero-padded. | 01 | 
| Minutes and seconds | ||
| i | Minutes past the hour, zero-padded. | 22 | 
| s | Seconds past the minute, zero-padded. | 38 | 
| U | Seconds since January 1 1970 00:00:00 GMT. | 1762219358 | 
| Timezone (as of 1.22wmf2) | ||
| e | Timezone identifier. | UTC | 
| I | Whether or not the date is in daylight savings time. | 0 | 
| O | Difference to Greenwich time (GMT) | +0000 | 
| P | Difference to Greenwich time (GMT), with colon | +00:00 | 
| T | Timezone abbreviation. | UTC | 
| Z | Timezone offset in seconds. | 0 | 
| Miscellaneous | ||
| t | Number of days in the current month. | 30 | 
| c | ISO 8601 formatted date, equivalent to Y-m-d"T"H:i:s+00:00. | 2025-11-04T01:22:38+00:00 | 
| r | RFC 5322 formatted date, equivalent to D, j M Y H:i:s +0000, with weekday name and month name not internationalised. | Tue, 04 Nov 2025 01:22:38 +0000 | 
| Non-Gregorian calendars | ||
| Islamic | ||
| xmj | Day of the month. | 13 | 
| xmF | Full month name. | Jumada al-awwal | 
| xmn | Month index. | 5 | 
| xmY | Full year. | 1447 | 
| Iranian (Jalaly) | ||
| xij | Day of the month. | 13 | 
| xiF | Full month name. | Aban | 
| xin | Month index. | 8 | 
| xiY | Full year. | 1404 | 
| xiy | 2-digit year. | 04 | 
| Hebrew | ||
| xjj | Day of the month. | 13 | 
| xjF | Full month name. | Cheshvan | 
| xjt | Number of days in month. | 29 | 
| xjx | Genitive form of the month name. | Cheshvan | 
| xjn | Month number. | 2 | 
| xjY | Full year. | 5786 | 
| Thai solar | ||
| xkY | Full year. | 2568 | 
| Minguo/Juche year | ||
| xoY | Full year. | 114 | 
| Japanese nengo | ||
| xtY | Full year. | 令和7 | 
| 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 10,000 (up to 3,000 in pre MediaWiki 1.20).  | 
{{#time:xrY}} → MMXXV | 
| xh | Format the next number as a Hebrew numeral. | {{#time:xhY}} → ב'כ"ה | 
See also
- Template:Time, the current date/time
 - Template:Now, shows a sentence with the current date/time
 - Template:TODAY, shows only the current date, in typical dmy form
 - Template:Today, a navbox about the U.S. daily TV talk-show Today
 - mw:Help:Extension:ParserFunctions # #time, developer's documentation page
 - Unix time