Template:Date difference/doc: Difference between revisions

From NPOWiki
Jump to navigation Jump to search
create
 
mNo edit summary
 
(3 intermediate revisions by the same user not shown)
Line 3: Line 3:
This template is used to calculate the number of days between two given dates, or one date and the current date. (More features can be added as needed.)
This template is used to calculate the number of days between two given dates, or one date and the current date. (More features can be added as needed.)


Use the "formatnum" [[mw:Help:Magic words|magic word]] to add thousands separators when desired.
Use the "formatnum" [[mw:Help:Magic words|magic word]] to add thousands separators when desired. Note that it is technically more efficient when there is an end date to replace the template call with its result, which can be accomplished more easily with the subst: magic word (see [[mw:Help:Substitution]]).
 
This template makes use of Lua code at [[Module:Date difference]]. Please use the template rather than invoking the module directly.


==Parameters==
==Parameters==
Line 19: Line 21:
*<code><nowiki>{{date difference|August 31, 2015|November 17, 2016}}</nowiki></code> produces: {{date difference|August 31, 2015|November 17, 2016}}
*<code><nowiki>{{date difference|August 31, 2015|November 17, 2016}}</nowiki></code> produces: {{date difference|August 31, 2015|November 17, 2016}}


<includeonly></includeonly>
<includeonly>[[Category:Calculation templates]]</includeonly>

Latest revision as of 00:14, 11 October 2025

This page contains the documentation for Template:Date difference. It includes information about the template, such as usage and categories, and is not displayed when using the template itself.

This template is used to calculate the number of days between two given dates, or one date and the current date. (More features can be added as needed.)

Use the "formatnum" magic word to add thousands separators when desired. Note that it is technically more efficient when there is an end date to replace the template call with its result, which can be accomplished more easily with the subst: magic word (see mw:Help:Substitution).

This template makes use of Lua code at Module:Date difference. Please use the template rather than invoking the module directly.

Parameters

  • first unnamed parameter: the start date.
  • second unnamed parameter: (optional) the end date; defaults to the current date.

Each parameter must be in one of the following formats in order for the software to recognize the date unambiguously:

  • January 31, 2020
  • 31 January 2020
  • 2020-01-31

Examples

  • {{date difference|January 27, 2006}} produces: 7252
  • {{formatnum:{{date difference|January 27, 2006}}}} produces: 7,252
  • {{date difference|August 31, 2015|November 17, 2016}} produces: 444