Jump to content


From mediawiki.org
MediaWiki extensions manual
Release status: stable
Implementation Parser function
Description Takes two dates and returns all intermediary days
Author(s) Kwisatz, Jeroen De Dauw
Latest version 0.4.0 (2021-11-11)
MediaWiki 1.25+
PHP 7.2+
Database changes No
License Creative Commons Attribution Share Alike 3.0
Example sandbox.semantic-mediawiki.org
Quarterly downloads 2 (Ranked 136th)
Translate the DateDiff extension if it is available at translatewiki.net

The DateDiff extension adds the #dates parser function that returns a list of intermediary days.


The #dates parser function comes with two parameters |StartDate and |EndDate which is used as follows:

{{#dates:|StartDate=2016/10/01 |EndDate=2016/10/02 }}



A typical use case are events in a semantic setup that span multiple days. In order to have the events appear on all days on a calendar provided by the Semantic Result Formats extension, you would use something like (requires the ParserFunctions extension):

{{#ifeq: {{{recurring}}} |no |{{#set: Has date={{#dates:|StartDate={{{from}}} |EndDate={{{till}}} }} |+sep=, }} }}

Number of days between two days (requires the Arrays extension):

{{#arraydefine:days|{{#dates:|StartDate=2015-04-01 |EndDate=2015-04-10 }} }}


  • Download and move the extracted DateDiff folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/DateDiff
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'DateDiff' );
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

To users running MediaWiki 1.39 or earlier:

The instructions above describe the new way of installing this extension using wfLoadExtension(). If you need to install this extension on these earlier versions (MediaWiki 1.39 and earlier), instead of wfLoadExtension( 'DateDiff' );, you need to use:

require_once "$IP/extensions/DateDiff/DateDiff.php";