WP:Date math

Date math on Wikipedia is done with variables, templates and the #time parser function.

In articles, it is almost always preferred to specify a specific static date for a statement or event rather than an automatically generated date. Wikipedia:As of describes how to properly specify such dates.

Current date and time

class="wikitable"

! Built-in variables

! Templates based on them

! What you see

! Comments

{{CURRENTTIMESTAMP}}

|

| {{CURRENTTIMESTAMP}}

|

rowspan="4" style="vertical-align: top" | {{CURRENTYEAR}}

|

| {{CURRENTYEAR}}

|

{{tl|UTC}}

| {{UTC}}

| also uses {{CURRENTMONTH}} {{CURRENTDAY2}} {{CURRENTTIME}}

{{tl|CURRENTDATE}}

| {{CURRENTDATE}}

| also uses {{CURRENTTIME}} {{CURRENTDAYNAME}} {{CURRENTMONTHNAME}} {{CURRENTDAY}}

{{tl|CURRENTJULIANDAY}}

| {{CURRENTJULIANDAY}}

| current Julian day also uses {{CURRENTMONTH}} {{CURRENTDAY}} {{CURRENTHOUR}} {{tl|CURRENTMINUTE}} {{tl|CURRENTSECOND}}

rowspan="2" style="vertical-align: top" | {{CURRENTMONTH}}

|

| {{CURRENTMONTH}}

|

{{tl|CURRENTMNTH}}

| {{CURRENTMNTH}}

| trims leading zero

rowspan="4" style="vertical-align: top" | {{CURRENTMONTHNAME}}

|

| {{CURRENTMONTHNAME}}

|

{{tl|Month+1}}

| {{Month+1}}

|

{{tl|Month-1}}

| {{Month-1}}

|

{{tl|Month-2}}

| {{Month-2}}

|

{{CURRENTDAY}}

|

| {{CURRENTDAY}}

| day of month

rowspan="4" style="vertical-align: top" | {{CURRENTDOW}}

|

| {{CURRENTDOW}}

| day of week

{{#time:l
1 day}}

| {{#time:l

1 day}}

|

{{#time:l}}

| {{#time:l}}

|

{{#time:l|+1 day}}

| {{#time:l|+1 day}}

|

colspan="4" style="background:#DDDDDD;" | Any variable or template with a resolution of smaller than one day should not be placed in articles. These variables only indicate when the article was parsed and cached; they may lag by many hours or even days compared to the time the page is viewed.
{{CURRENTTIME}}

|

| {{CURRENTTIME}}

|

rowspan="3" style="vertical-align: top" | {{CURRENTHOUR}}

|

| {{CURRENTHOUR}}

|

{{#time:H|+1 hour}}

|{{#time:H|+1 hour}}

|

{{tl|Current hour}}

| {{Current hour}}

| trims leading zero

rowspan="3" style="vertical-align: top" | {{#time:i}}

|

| {{#time:i}}

|

{{tl|CURRENTMINUTE}}

| {{CURRENTMINUTE}}

|

{{tl|Current minute}}

| {{Current minute}}

| trims leading zero

rowspan="2" style="vertical-align: top" | {{#time:s}}

|

| {{#time:s}}

|

{{tl|CURRENTSECOND}}

| {{CURRENTSECOND}}

|

Computed date and time

class="wikitable"

! Template name

! Usage

! Output

! Comment

rowspan="2" style="vertical-align: top" | {{tl|Ordinal date}}

| {{Ordinal date|year=2007|month=03|day=15}}

| {{Ordinal date|year=2007|month=03|day=15}}

| returns ordinal date (day of year)

{{Ordinal date|year=2008|month=03|day=15}}

| {{Ordinal date|year=2008|month=03|day=15}}

| +1 due to leap year in 2008

rowspan="2" style="vertical-align: top" | {{tl|WEEKDAY}}

| {{WEEKDAY|2009|08|25}}

| {{WEEKDAY|2009|08|25}}

| returns day of week

{{WEEKDAYNAME|{{WEEKDAY|2009|08|25}}}}

| {{WEEKDAYNAME|{{WEEKDAY|2009|08|25}}}}

|

rowspan="3" style="vertical-align: top" | {{tl|JULIANDAY}}

| {{JULIANDAY|2009|08|25}}

| {{JULIANDAY|2009|08|25}}

|

{{WEEKDAYNAME|{{JULIANDAY|2009|08|25}}}}

| {{WEEKDAYNAME|{{JULIANDAY|2009|08|25}}}}

| Note: 2455069 mod 7 = {{#expr:2455069 mod 7}}

{{JULIANDAY|{{CURRENTYEAR}}|{{CURRENTMONTH}}|{{CURRENTDAY}}}}

| {{JULIANDAY|{{CURRENTYEAR}}|{{CURRENTMONTH}}|{{CURRENTDAY}}}}

| Nesting templates to get the value of the current Julian day with no decimal portion. Useful for date math between a set point and the current date.

rowspan="2" style="vertical-align: top" | {{tl|JULIANDAY.TIMESTAMP}}

| {{JULIANDAY.TIMESTAMP|2455069}}

| {{JULIANDAY.TIMESTAMP|2455069}}

| same format as {{CURRENTTIMESTAMP}}

{{nowrap|{{#time:D Y-m-d|{{JULIANDAY.TIMESTAMP|2455069}}}}}}

| {{#time:D Y-m-d|{{JULIANDAY.TIMESTAMP|2455069}}}}

|

Julian dates or day numbers can be used for date calculations. A simple example follows:

  1. 90 days from 25 December 2006 is: {{#time:j F Y|{{JULIANDAY.TIMESTAMP|{{JULIANDAY|2006|12|25}}+90}}}}
  2. * Code: {{#time:j F Y|{{JULIANDAY.TIMESTAMP|{{JULIANDAY|2006|12|25}}+90}}}}
  3. 90 days from 25 December 2007 is: {{#time:j F Y|{{JULIANDAY.TIMESTAMP|{{JULIANDAY|2007|12|25}}+90}}}} (1 day less than first example due to leap year in 2008)
  4. * Code: {{#time:j F Y|{{JULIANDAY.TIMESTAMP|{{JULIANDAY|2007|12|25}}+90}}}}

Fancy stuff

{{today cell}}

| {{tomorrow cell}}

{{tl|today cell}}

| {{tl|tomorrow cell}}

See also