Help:Date and time parser

From Ballotpedia
Jump to: navigation, search

Time parsers allow you to post the current date and server time on a page of the wiki.

The Code

The code on the page reads:

Formatting code

The following code can be used to format the date and time as it appears in the parser (This table was taken from Mediawiki Help:Extension:ParserFunctions):

Code Description Current output
(Purge this page's cache to update)
Y 4-digit year. 2014
y 2-digit year. 14
L 1 or 0 whether it's a leap year or not. 0
o ¹ ISO-8601 year number. ² 2014 ³

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

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
W ISO 8601 week number, zero-padded. 31
j Day of the month, not zero-padded. 29
d Day of the month, zero-padded. 29
z Day of the year (January 1 = 0).
Note: To get the ISO day of the year add 1.
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
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. 51
s Seconds past the minute, zero-padded. 23
U Seconds since January 1 1970 00:00:00 GMT. 1406663483
t Number of days in the current month. 31
c ISO 8601 formatted date, equivalent to Y-m-dTH:i:s+00:00. 2014-07-29T19:51:23+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, 29 Jul 2014 19:51:23 +0000

Notes on time

  • Time expression works on the server time according to the wiki settings. You should compare the current server time with your current time. Current server time is 7:51:23 pm, Tuesday, July 29, 14
  • You can adjust the time to align with U.S. time zones with the following code:
Time ZoneCodeExample
Eastern Standard Time{{#time: g:i:s a, l, F j, Y "EST"| now - 4 hours}} 3:51:23 pm, Tuesday, July 29, 2014 EST
Central Time{{#time: g:i:s a, l, F j, Y "CT"| now - 5 hours}} 2:51:23 pm, Tuesday, July 29, 2014 CT
Mountain Time{{#time: g:i:s a, l, F j, Y "MT"| now - 6 hours}} 1:51:23 pm, Tuesday, July 29, 2014 MT
Pacific Time{{#time: g:i:s a, l, F j, Y "PT" | now - 7 hours}} 12:51:23 pm, Tuesday, July 29, 2014 PT