#time সম্পাদনা কৰক

Code Description Current output
(Purge this page's cache to update)
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. 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. 20
d Day of the month, zero-padded. 20
z Day of the year (January 1 = 0).
[[#ref_{{{1}}}|^]] To get the ISO day of the year add 1.
110
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). 6
w Number of the day of the week (Sunday = 0, Saturday = 6). 6
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. 7
h Hour in 12-hour format, zero-padded. 07
G Hour in 24-hour format, not zero-padded. 19
H Hour in 24-hour format, zero-padded. 19
Minutes and seconds
i Minutes past the hour, zero-padded. 49
s Seconds past the minute, zero-padded. 00
U Seconds since January 1 1970 00:00:00 GMT. 1713642540
Miscellaneous
t Number of days in the current month. 30
c ISO 8601 formatted date, equivalent to Y-m-dTH:i:s+00:00. 2024-04-20T19:49:00+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. Sat, 20 Apr 2024 19:49:00 +0000
Non-Gregorian calendars
Islamic
xmj Day of the month. 11
xmF Full month name. Shawwal
xmn Month index. 10
xmY Full year. 1445
Iranian
xij Day of the month. 1
xiF Full month name. Ordibehesht
xin Month index. 2
xiY Full year. 1403
Hebrew
xjj Day of the month. 12
xjF Full month name. Nisan
xjt Number of days in month. 30
xjx Genitive form of the month name. Nisan
xjn Month number. 7
xjY Full year. 5784
Thai solar
xkY Full year. 2567
Minguo/Juche year
xoY Full year. 113
Japanese nengo
xtY Full year. 令和6
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
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:

  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".

{{#time: Y-m-d }}2024-04-20
{{#time: [[Y]] m d }}2024 04 20
{{#time: [[Y (year)]] }}2024 (24UTCpmSat, 20 Apr 2024 19:49:00 +0000)
{{#time: [[Y "(year)"]] }}2024 (year)
{{#time: i's" }}49'00"

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}}Sat, 20 Apr 2024 19:49:00 +0000
{{#time: r|+2 hours}}Sat, 20 Apr 2024 21:49:00 +0000
{{#time: r|now + 2 hours}}Sat, 20 Apr 2024 21:49:00 +0000

If you've calculated a Unix timestamp, you may use it in date calculations by pre-pending an @ symbol.

{{#time: U | now }}1713642540
{{#time: r|@1713642540}}Sat, 20 Apr 2024 19:49:00 +0000

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 }}2024

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 20 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 }}2024 04 20 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}}2024-March

The total length of the format strings of the calls of #time is limited to 6000 characters [1].