Help:Time function
Appearance
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.
Template:Hl1 | Code | Template:Hl1 | Description | Template:Hl1 | Current output (Purge this page's cache to update) |
---|---|---|
Template:Hl2 colspan="3"| 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. | ||
Template:Hl2 colspan="3"| Month | ||
n | Month index, not zero-padded. | 7 |
m | Month index, zero-padded. | 07 |
M | An abbreviation of the month name, in the site language. | Jul |
F | The full month name in the site language. | July |
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 |
Template:Hl2 colspan="3"| Week | ||
W | ISO 8601 week number, zero-padded. | 27 |
Template:Hl2 colspan="3"| Day | ||
j | Day of the month, not zero-padded. | 3 |
d | Day of the month, zero-padded. | 03 |
z | Day of the year (January 1 = 0).¹ | 183 |
D | An abbreviation for the day of the week. Rarely internationalised. | Thu |
l | The full weekday name. Rarely internationalised. | Thursday |
N | ISO 8601 day of the week (Monday = 1, Sunday = 7). | 4 |
w | Number of the day of the week (Sunday = 0, Saturday = 6). | 4 |
¹ To get the ISO day of the year add 1. | ||
Template:Hl2 colspan="3"| 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. | 6 |
h | Hour in 12-hour format, zero-padded. | 06 |
G | Hour in 24-hour format, not zero-padded. | 6 |
H | Hour in 24-hour format, zero-padded. | 06 |
Template:Hl2 colspan="3"| Minutes and seconds | ||
i | Minutes past the hour, zero-padded. | 58 |
s | Seconds past the minute, zero-padded. | 26 |
U | Seconds since January 1 1970 00:00:00 GMT. | 1751525906 |
id="TimeZone" Template:Hl2 colspan="3"| 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 |
Template:Hl2 colspan="3"| Miscellaneous | ||
t | Number of days in the current month. | 31 |
c | ISO 8601 formatted date, equivalent to Y-m-d"T"H:i:s+00:00. | 2025-07-03T06:58:26+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. | Thu, 03 Jul 2025 06:58:26 +0000 |
Template:Hl2 colspan="3" | Non-Gregorian calendars | ||
Template:Hl3 colspan="3" | Islamic | ||
xmj | Day of the month. | 7 |
xmF | Full month name. | Muharram |
xmn | Month index. | 1 |
xmY | Full year. | 1447 |
Template:Hl3 colspan="3" | Iranian (Jalaly) | ||
xij | Day of the month. | 12 |
xiF | Full month name. | Tir |
xin | Month index. | 4 |
xiY | Full year. | 1404 |
xiy | 2-digit year. | 04 |
Template:Hl3 colspan="3" | Hebrew | ||
xjj | Day of the month. | 7 |
xjF | Full month name. | Tamuz |
xjt | Number of days in month. | 29 |
xjx | Genitive form of the month name. | Tamuz |
xjn | Month number. | 10 |
xjY | Full year. | 5785 |
Template:Hl3 colspan="3" | Thai solar | ||
xkY | Full year. | 2568 |
Template:Hl3 colspan="3" | Minguo/Juche year | ||
xoY | Full year. | 114 |
Template:Hl3 colspan="3" | Japanese nengo | ||
xtY | Full year. | 令和7 |
Template:Hl2 colspan="3" | 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}} → ב'כ"ה |