সদস্য:Bishnu Saikia/sandbox/ParserFunctions
#time
[সম্পাদনা কৰক]| Code | Description | Current output (Purge this page's cache to update) |
|---|---|---|
| Year | ||
| Y | 4-digit year. | 2026 |
| y | 2-digit year. | 26 |
| L | 1 or 0 whether it's a leap year or not. | 0 |
| o ¹ | ISO-8601 year number. ² | 2026 ³ |
|
¹ Requires PHP 5.1.0 and newer and rev:45208. | ||
| Month | ||
| n | Month index, not zero-padded. | 4 |
| m | Month index, zero-padded. | 04 |
| M | An abbreviation of the month name, in the site language. | এপ্ৰি |
| F | The full month name in the site language. | April |
| 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 |
| Week | ||
| W | ISO 8601 week number, zero-padded. | 16 |
| Day | ||
| j | Day of the month, not zero-padded. | 19 |
| d | Day of the month, zero-padded. | 19 |
| z | Day of the year (January 1 = 0). [[#ref_{{{1}}}|^]] To get the ISO day of the year add 1. |
108 |
| D | An abbreviation for the day of the week. Rarely internationalised. | দেও |
| l | The full weekday name. Rarely internationalised. | দেওবাৰ |
| N | ISO 8601 day of the week (Monday = 1, Sunday = 7). | 7 |
| w | Number of the day of the week (Sunday = 0, Saturday = 6). | 0 |
| 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. | 3 |
| h | Hour in 12-hour format, zero-padded. | 03 |
| G | Hour in 24-hour format, not zero-padded. | 3 |
| H | Hour in 24-hour format, zero-padded. | 03 |
| Minutes and seconds | ||
| i | Minutes past the hour, zero-padded. | 06 |
| s | Seconds past the minute, zero-padded. | 33 |
| U | Seconds since January 1 1970 00:00:00 GMT. | 1776567993 |
| Miscellaneous | ||
| t | Number of days in the current month. | 30 |
| c | ISO 8601 formatted date, equivalent to Y-m-dTH:i:s+00:00. | 2026-04-19T03:06:33+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. | Sun, 19 Apr 2026 03:06:33 +0000 |
| Non-Gregorian calendars | ||
| Islamic | ||
| xmj | Day of the month. | 2 |
| xmF | Full month name. | Dhu al-Qi'dah |
| xmn | Month index. | 11 |
| xmY | Full year. | 1447 |
| Iranian | ||
| xij | Day of the month. | 30 |
| xiF | Full month name. | Farvardin |
| xin | Month index. | 1 |
| xiY | Full year. | 1405 |
| Hebrew | ||
| xjj | Day of the month. | 2 |
| xjF | Full month name. | Iyar |
| xjt | Number of days in month. | 29 |
| xjx | Genitive form of the month name. | Iyar |
| xjn | Month number. | 8 |
| xjY | Full year. | 5786 |
| Thai solar | ||
| xkY | Full year. | 2569 |
| Minguo/Juche year | ||
| xoY | Full year. | 115 |
| Japanese nengo | ||
| xtY | Full year. | 令和8 |
| 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}} → MMXXVI |
| xh | Format the next number as a Hebrew numeral. | {{#time:xhY}} → ב'כ"ו |
This 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 }}
The list of accepted formatting codes is given in the table to the right. 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 }} → 2026-04-19
- {{#time: [[Y]] m d }} → 2026 04 19
- {{#time: [[Y (year)]] }} → 2026 (26UTCamSun, 19 Apr 2026 03:06:33 +0000)
- {{#time: [[Y "(year)"]] }} → 2026 (year)
- {{#time: i's" }} → 06'33"
The date/time object can be in any format accepted by PHP's strtotime() function. Both absolute (eg 20 December 2000) and relative (eg +20 hours) times are accepted.
{{#time: r|now}} → Sun, 19 Apr 2026 03:06:33 +0000
{{#time: r|+2 hours}} → Sun, 19 Apr 2026 05:06:33 +0000
{{#time: r|now + 2 hours}} → Sun, 19 Apr 2026 05:06:33 +0000
If you've calculated a Unix timestamp, you may use it in date calculations by pre-pending an @ symbol.
{{#time: U | now }} → 1776567993
{{#time: r|@1776567993}} → Sun, 19 Apr 2026 03:06:33 +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 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 }} → 2026
|
|
The fill-in feature is not consistent; some parts are filled in using the current values, others are not: {{#time: Y m d H:i:s | June }} → 2026 06 19 00:00:00 Gives the start of the day, but the current day of the month and the current year. {{#time: Y m d H:i:s | 2003 }} → 2003 04 19 00:00:00 Gives the start of the day, but the current day of the year. |
With MediaWiki r86805 - Code Review, a four-digit number is always interpreted as a year, never as hours and minutes:
{{#time: Y m d H:i:s | 1959 }} → 1959 04 19 00:00:00
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: Y m d H:i:s | 195909 }} → 2026 04 19 19:59:09 Input is treated as a time rather than a year+month code.
{{#time: Y m d H:i:s | 196009 }} → ভুল: অযোগ্য সময় Although 19:60:09 is not a valid time, 196009 is not interpreted as September 1960.
The function performs a certain amount of date mathematics:
- {{#time: d F Y | January 0 2008 }} → 31 December 2007
- {{#time: d F | January 32 }} → ভুল: অযোগ্য সময়
- {{#time: d F | February 29 2008 }} → 29 February
- {{#time: d F | February 29 2007 }} → 01 March
- {{#time:Y-F|now -1 months}} → 2026-March
The total length of the format strings of the calls of #time is limited to 6000 characters [1].