FANDOM



Export this template, then import, to install it.
Use edit summary: Copied from [[w:c:templates:Template:Date]] to properly attribute this template's editors.
This template is probably not already on your wiki.
Template documentation
Note: the template above may sometimes be partially or fully invisible.

View or edit this documentation. (How does this work?)

Editors can experiment with this template's sandbox and test case pages.
Description
A date library that has many functions to manipulate dates, based on http://tieske.github.io/date/
Syntax
{{date|functioname|date|arg1|...}}
Syntax for (diff | epoch | isleapyear)

{{date|functioname|date|arg1|...}}
{{date|diff|YYYY/MM/DD|YYYY/MM/DD}} e.g. {{date|diff|2010/12/10|2010/12/09}} → -1
{{date|isleapyear|YYYY/MM/DD}} e.g. {{date|isleapyear|2010/10/10}} → false

Functions

adddays | addhours | addminutes | addmonths | addseconds | addticks | addyears | copy | fmt | getbias | getclockhour | getdate | getday | getfracsec | gethours | getisoweekday | getisoweeknumber | getisoyear | getminutes | getmonth | getseconds | getticks | gettime | getweekday | getweeknumber | getyear | getyearday | setday | sethours | setisoweekday | setisoweeknumber | setisoyear | setminutes | setmonth | setseconds | setticks | setyear | spandays | spanhours | spanminutes | spanseconds | spanticks | tolocal | toutc

Format options
http://tieske.github.io/date/#dateObject.fmt

Table 3. Format Spec

Spec Description
'%a' Abbreviated weekday name (Sun)
'%A' Full weekday name (Sunday)
'%b' Abbreviated month name (Dec)
'%B' Full month name (December)
'%C' Year/100 (19, 20, 30)
'%d' The day of the month as a number (range 1 - 31)
'%g' year for ISO 8601 week, from 00 (79)
'%G' year for ISO 8601 week, from 0000 (1979)
'%h' same as %b
'%H' hour of the 24-hour day, from 00 (06)
'%I' The hour as a number using a 12-hour clock (01 - 12)
'%j' The day of the year as a number (001 - 366)
'%m' Month of the year, from 01 to 12
'%M' Minutes after the hour 55
'%p' AM/PM indicator (AM)
'%S' The second as a number (59, 20 , 01)
'%u' ISO 8601 day of the week, to 7 for Sunday (7, 1)
'%U' Sunday week of the year, from 00 (48)
'%V' ISO 8601 week of the year, from 01 (48)
'%w' The day of the week as a decimal, Sunday being 0
'%W' Monday week of the year, from 00 (48)
'%y' The year as a number without a century (range 00 to 99)
'%Y' Year with century (2000, 1914, 0325, 0001)
'%z' Time zone offset, the date object is assumed local time (+1000, -0230)
'%Z' Time zone name, the date object is assumed local time
'%\b' Year, if year is in BCE, prints the BCE Year representation, otherwise result is similar to "%Y" (1 BCE, 40 BCE) #
'%\f' Seconds including fraction (59.998, 01.123) #
'%%' percent character %
'%r' 12-hour time, from 01:00:00 AM (06:55:15 AM); same as "%I:%M:%S %p"
'%R' hour:minute, from 01:00 (06:55); same as "%I:%M"
'%T' 24-hour time, from 00:00:00 (06:55:15); same as "%H:%M:%S"
'%D' month/day/year from 01/01/00 (12/02/79); same as "%m/%d/%y"
'%F' year-month-day (1979-12-02); same as "%Y-%m-%d"
'%c' The preferred date and time representation; same as "%x %X"
'%x' The preferred date representation, same as "%a %b %d %\b"
'%X' The preferred time representation, same as "%H:%M:%\f"
'${iso}' Iso format, same as "%Y-%m-%dT%T"
'${http}' http format, same as "%a, %d %b %Y %T GMT"
'${ctime}' ctime format, same as "%a %b %d %T GMT %Y"
'${rfc850}' RFC850 format, same as "%A, %d-%b-%y %T GMT"
'${rfc1123}' RFC1123 format, same as "%a, %d %b %Y %T GMT"
'${asctime}' asctime format, same as "%a %b %d %T %Y"
Example
{{date|adddays|2010/10/10|5}} →Fri Oct 15 2010 00:00:00
{{date|fmt|{{date|adddays|2010/10/10|5}}|%F}} → 2010-10-15

Requires

Community content is available under CC-BY-SA unless otherwise noted.