Wiki143: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
| Built-in variables | Templates based on them | What you see | Comments |
|---|---|---|---|
| {{CURRENTTIMESTAMP}} | 20251222155213 | ||
| {{CURRENTYEAR}} | 2025 | ||
| Template:Tl | Template:UTC | also uses {{CURRENTMONTH}} {{CURRENTDAY2}} {{CURRENTTIME}} | |
| Template:Tl |
|
also uses {{CURRENTTIME}} {{CURRENTDAYNAME}} {{CURRENTMONTHNAME}} {{CURRENTDAY}} | |
| Template:Tl | 2461032.1612616 | current Julian day also uses {{CURRENTMONTH}} {{CURRENTDAY}} {{CURRENTHOUR}} Template:Tl Template:Tl | |
| {{CURRENTMONTH}} | 12 | ||
| Template:Tl | 12 | trims leading zero | |
| {{CURRENTMONTHNAME}} | December | ||
| Template:Tl | January | ||
| Template:Tl | November | ||
| Template:Tl | October | ||
| {{CURRENTDAY}} | 22 | day of month | |
| {{CURRENTDOW}} | 1 | day of week | |
| {{#time:l|-1 day}} | Sunday | ||
| {{#time:l}} | Monday | ||
| {{#time:l|+1 day}} | Tuesday | ||
| 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}} | 15:52 | ||
| {{CURRENTHOUR}} | 15 | ||
| {{#time:H|+1 hour}} | 16 | ||
| Template:Tl | Template:Current hour | trims leading zero | |
| {{#time:i}} | 52 | ||
| Template:Tl | 52 | ||
| Template:Tl | 52 | trims leading zero | |
| {{#time:s}} | 13 | ||
| Template:Tl | 13 | ||
Computed date and time
| Template name | Usage | Output | Comment |
|---|---|---|---|
| Template:Tl | {{Ordinal date|year=2007|month=03|day=15}} | 74 | returns ordinal date (day of year) |
| {{Ordinal date|year=2008|month=03|day=15}} | 75 | +1 due to leap year in 2008 | |
| Template:Tl | {{WEEKDAY|2009|08|25}} |
|
returns day of week |
| {{WEEKDAYNAME|{{WEEKDAY|2009|08|25}}}} | |||
| Template:Tl | {{JULIANDAY|2009|08|25}} | 2455069 | |
| {{WEEKDAYNAME|{{JULIANDAY|2009|08|25}}}} | Tuesday | Note: 2455069 mod 7 = 1 | |
| {{JULIANDAY|{{CURRENTYEAR}}|{{CURRENTMONTH}}|{{CURRENTDAY}}}} | 2461032 | 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. | |
| Template:Tl | {{JULIANDAY.TIMESTAMP|2455069}} | Template:JULIANDAY.TIMESTAMP | same format as {{CURRENTTIMESTAMP}} |
| {{#time:D Y-m-d|{{JULIANDAY.TIMESTAMP|2455069}}}} | Error: Invalid time. |
Julian dates or day numbers can be used for date calculations. A simple example follows:
- 90 days from 25 December 2006 is: Error: Invalid time.
- Code: {{#time:j F Y|{{JULIANDAY.TIMESTAMP|{{JULIANDAY|2006|12|25}}+90}}}}
- 90 days from 25 December 2007 is: Error: Invalid time. (1 day less than first example due to leap year in 2008)
- Code: {{#time:j F Y|{{JULIANDAY.TIMESTAMP|{{JULIANDAY|2007|12|25}}+90}}}}
Fancy stuff
| Template:Tomorrow cell | |
| Template:Tl | Template:Tl |