Template:DateDiff/doc

From RuneRealm Wiki

This is the current revision of this page, as edited by Alex (talk | contribs) at 00:23, 17 October 2024 (Created page with "{{Documentation}} :''This template is only applicable for dates from 1 January 1970 onwards only.'' The '''DateDiff''' returns the difference in days (possibly with decimals) between two dates in the Gregorian calendar. The return value is positive if <code>date2</code> comes ''after'' <code>date1</code>, and is negative if <code>date2</code> comes ''before'' <code>date1</code> (i.e. the template computes <code>date2 - date1</code>). ===Usage=== If two dates supplied..."). The present address (URL) is a permanent link to this version.

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
This is a documentation subpage for Template:DateDiff.
It contains usage information, categories, and other content that is not part of the original template page.
This template is only applicable for dates from 1 January 1970 onwards only.

The DateDiff returns the difference in days (possibly with decimals) between two dates in the Gregorian calendar. The return value is positive if date2 comes after date1, and is negative if date2 comes before date1 (i.e. the template computes date2 - date1).

Usage

If two dates supplied, the template calculates the difference between them, in days. If only one date is supplied, then the supplied date is calculated against the current date. If no dates are supplied, the template calculates the number of days from the start of the Julian epoch to the current date. If an invalid date is supplied, then the text is returned unaltered.

The inputted dates may be in any format understood by the #time: parser function. (e.g. July 18, 2008, 18 July 2008 and 2008-07-18 are all valid.) Hours, minutes and seconds can likewise be inputted.

This template can be used for dates from 1 January 1970 onwards only.

Examples

Code Output
{{DateDiff|18 July 2008|2008-07-16}} -2
{{DateDiff|July 16, 2008 8PM|2008-07-18 8:00:00}} 1.5
{{DateDiff|2008-07-18}} 5993.1401968002
{{DateDiff|{{#time:c}}}} should always equal zero
{{DateDiff}} 739631.1401968
{{DateDiff|invalid}} invalid

See also