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:
{{#time: FORMATTING CODE }}

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)
Year
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
Week
W ISO 8601 week number, zero-padded. 28
Day
j Day of the month, not zero-padded. 11
d Day of the month, zero-padded. 11
z Day of the year (January 1 = 0).
Note: To get the ISO day of the year add 1.
191
D An abbreviation for the day of the week. Rarely internationalised. Fri
l The full weekday name. Rarely internationalised. Friday
N ISO 8601 day of the week (Monday = 1, Sunday = 7). 5
w Number of the day of the week (Sunday = 0, Saturday = 6). 5
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. 9
h Hour in 12-hour format, zero-padded. 09
G Hour in 24-hour format, not zero-padded. 21
H Hour in 24-hour format, zero-padded. 21
Minutes and seconds
i Minutes past the hour, zero-padded. 20
s Seconds past the minute, zero-padded. 19
U Seconds since January 1 1970 00:00:00 GMT. 1405113619
Miscellaneous
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-11T21:20:19+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. Fri, 11 Jul 2014 21:20:19 +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 9:20:19 pm, Friday, July 11, 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}} 5:20:19 pm, Friday, July 11, 2014 EST
Central Time{{#time: g:i:s a, l, F j, Y "CT"| now - 5 hours}} 4:20:19 pm, Friday, July 11, 2014 CT
Mountain Time{{#time: g:i:s a, l, F j, Y "MT"| now - 6 hours}} 3:20:19 pm, Friday, July 11, 2014 MT
Pacific Time{{#time: g:i:s a, l, F j, Y "PT" | now - 7 hours}} 2:20:19 pm, Friday, July 11, 2014 PT


References