It's better when it's simple

User Tools

Site Tools


Countdown Plugin

Compatible with DokuWiki

  • 2020-07-29 "Hogfather" unknown
  • 2018-04-22 "Greebo" yes
  • 2017-02-19 "Frusterick Manners" yes
  • 2016-06-26 "Elenor Of Tsort" unknown

plugin Countdown to a specific date

Last updated on

Tagged with counter, date

The Countdown Plugin shows a countdown to a specific (target) date.

Under new management since June 11, 2009.
-Previously maintained by Ekkart Kleinod (since version 2.x).
-Based on even earlier work by Ron Peters (version 1.0).
-Which was itself a modified version of the nucleuswiki plugin by Trent Adams and Edmond Hui

Important: version 2.x is not compatible with version 1.0 (syntax change of date)

Download and Installation

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

As of the date of January 2019, the latest version is the version 2.6.

:!: It is recommended you upgrade the plugin if you are using PHP>=7.0 to avoid some warnings in the code, thanks to Stefan Huehner for the corrections. As the last version still needs to be recompiled, follow the solution bellow:

Warning: time() expects exactly 0 parameters, 1 given in …lib\plugins\countdown\syntax.php on line 140

  • Just remove “void” in line 140 to fix it ;) the result will be:
    • $t= time();

Previous Versions


:!: (Neo) Demo Site. The site is in Spanish, but usage should be pretty obvious and language is neutral enough that even Google Translator shall do fine. An English demo page will be made available for the next release of the plugin.

Examples of use and more information can be found on

The output of the countdown plugin, showing our remaining time to the
Mayan “End of Days” (2012-12-22).


With this plugin you can insert a countdown into your page where it will display the number of days, and optionally hours and minutes, until or since a specified timestamp, adding a description of the event as well.

The format is:


This will be replaced with either:

XX days [HH:MM] until description
XX days [HH:MM] since description

(where the [HH:MM] part is optional)

Possible formats of date are all GNU date formats that are allowed by strtotime. Examples:

<COUNTDOWN:mm/dd/yyyy|day to remember>

Disable Page Caching so the plugin text can remain dynamic, insert this into any page using this plugin:



The plugin is configurable in some ways since version 2.0.

There are six parameters that are configurable, via either local.php or the Configuration Manager:

Visibility of Countdown Date:

The parameter include_date is a Boolean that determines whether to show (true) or not (false) the target date in the output.


(with option disabled)
XX days until description
(with option enabled)
XX days until description (mm/dd/yyyy)

Short form for Today:

The parameter use_today is a Boolean that determines whether to switch the output of the countdown to the short, simple form “Today” if the countdown date is due today (true).


(with option enabled) 
Today is description

Display hours and minutes:

The parameter with_hours is a Boolean that determines whether to show hours and minutes as well as days in the output (true). It defaults to false to maintain output compatibility with previous versions of the plugin.


(with option enabled)
XX days HH:MM until description (mm/dd/yyyy)

Parameters in the Latest Release

Display business days

The parameter business_days is a Boolean that determines whether the amount of “business days” will be shown as well as the amount of total days. It defaults to false, The number of business days is currently calculated by merely omitting Saturdays and Sundays.


(with option enabled)
XX (BB) days until description

Server Time Message

This parameter is a Boolean that determines whether this plugin will add a notice to DokuWiki's notification bar indicating the current time the server is using for calculations. It defaults to false. This option might be useful for wikis installed in shared or virtual hosting, as they might be located in other timezones or even change timezones periodically.


(with option enabled)
(the following sample message will show on DokuWiki's notification bar)
Server time for Countdown plugin is: 2011-03-08 12:45


The output format of the date can be set in file lang/xx/lang.php where xx stands for your preferred language. This file contains the language dependent texts too. Feel free to edit these files or create new ones for your language. If you want your language file to be integrated into the plugin, please send them to me. Please tag your email subject with [countdown].

The following languages are included:

  • German (de), English (en) by Ekkart Kleinod
  • Estonian (et) by Mikk Leini
  • French (fr) by Gaby Armitage
  • Polish (pl) by Malgorzata Markiewicz
  • Swedish (sv) by Peter Hultqvist
  • Spanish (es) by Luis Machuca Bezzaza
  • Czech (cs) by Roman Šilar
  • Brazilian Portuguese (pt-br) by Adirson Maguila


  • :!: version 2.6 (2019-01-13): corrections for PHP >= 7.0. The source code is moved to an online repository as well.
  • version 2.5rc2 (2011-03-11) maintained by Luis Machuca Bezzaza: correction of a one-day-time bug and addition of the option to display business days and server time; minor overall improvements; compatibility.
  • version 2.5rc (2009-12-19) maintained by Luis Machuca Bezzaza: Czech, Spanish and Br-Portuguese language files, ability to display hours, general code rewrite to use getLang(), getConf capabilities, added README, CHANGELOG and VERSION.
  • version 2.1.3 (2009-01-24) maintained by Ekkart Kleinod: French language file
  • version 2.1.2 (2008-07-20) maintained by Ekkart Kleinod: Estonian language file
  • version 2.1.1 (2008-04-17) maintained by Ekkart Kleinod: Polish language file, Swedish language file correct 'today'
  • version 2.1 (2008-03-04) maintained by Ekkart Kleinod: bugfix header warning, bugfix day computation, new parameter use_today
  • version 2.0.1 (2008-02-20) maintained by Ekkart Kleinod: Swedish language file
  • version 2.0 (2008-02-18) maintained by Ekkart Kleinod: language and configuration options, code rewrite
  • version 1.0 maintained by Ron Peters: basic functionality


Does this plugin work properly with leap years?

Yes it does — Geoffrey Roberts 2008-02-02 12:23

There is a small bug with the plugin. Basically it miscounts the number of days as it does not round hours correctly. This can be fixed by replacing:

$the_time = sprintf("%.0f",abs($time));


$the_time = sprintf("%.0f",ceil(abs($time)));
I used floor instead of ceil for the new version 2.0. This works for me, can someone please confirm my results? Thanks, EK.
floor was wrong, ceil does the trick, even without abs()

How about <COUNTDOWN:mm/dd/yyyy&date|day to remember> or <COUNTDOWN:mm/dd/yyyy&nodate|day to remember> that can override the default config option?

Sounds good, depends on how much time I have these days. EK.

Is it possible to change the date input syntax to dd/mm/yyyy (for the UK) rather than mm/dd/yyyy? This would be much appreciated :)

And a french version too! if you find time for this…
XX jours avant

The ability to display “business days” would be very helpful for those who use this at work. Dumping in a little JavaScript or something to make it count down by the second would be neat to…

This feature has been added, albeit in a simple way, in version 2.5.rc2. — Luis Machuca Bezzaza 2011/03/12 20:41

:!: Just wanted people above to know that I have received two language packs for internationalization, and I'm working on a third of my own. With this and an attempt I'll make to incorporate the “business days” suggestion above, a new release will be ready by end of December 2009. — ryan.chappelle 2009/11/29 01:13

Done: version 2.5rc is now available. — ryan.chappelle 2009/12/21 19:56

Request: Add conditional formatting - e.g different hues from green to red, as deadline approaches? Or maybe just declare when up to e.g. 4 dates + the absolute deadline. for each date → new color. After deadline text becomes bold

Sounds interesting. I'll lift some code from a similar plugin at MediaWiki that seems to be capable of being formatted any way one wants, and check from there. — Luis 2010/06/03 21:01

Hi, is this an error? I´ve set the date to 8.9.2010 00:00 now is 07.09.2010 15:00 and the timer show 1 Day 09:00 but the event is in 9 houers. Is it posibel to show only the houers left if the event ist under 1 day away? I used this but i disable php on my wiki:

$timestamp = time();
$event = mktime(0,1,0,1,22,2010);
$day = ($event - $timestamp) / (60*60*24);
$houers = ($event - $timestamp) / (60*60);
$day= floor($day);
$houers = (($event - $timestamp - ($tage * 24*60*60)) / (60*60));
$houers= round($houers, 1);
echo $day," day ",$houers," houers left. ";
This was apparently a bug caused y leftover code, and seems to be fixed in the newest release.


We set the global wiki language “lang” to de-informal. Because there is no such dir in lang, language defaults to english. This was a bit tricky to find out. I set a symlink with “de-informal” to “de”, and now it works just fine.

Bug line 127 syntax.php :

        // check parsed date
        if ($parsedDate <= 0) {
          $renderer->doc .= $this->getLand('wrongformat'). $data[0] . ": " . $data[1];
        } else {

you have to change it to : (getLand –> getlang)

                  // check parsed date
        if ($parsedDate <= 0) {
          $renderer->doc .= $this->getLang('wrongformat'). $data[0] . ": " . $data[1];
        } else {
Will get to fix it. Thanks for letting me know! — ryan.chappelle 2010/11/03 16:50

Attention: new maintainer needed -> found

Due to changes in my homepage backend I no longer develop this plugin. I will host the plugin until a new maintainer is found. Please contact me if a new maintainer takes over the development.

Regards, Ekkart.

Hi, Ekkart. I've already mailed you asking to take over the development. But of course you might want to wait JIC someone else applies too. Kind regards. — Luis Machuca B. 2009/05/26 06:09
Hi Luis, sorry for not answering, I'm afraid, your mail was put into the spam folder. It's okay for me if you develop the plugin further. All files are in the zip archive. Regards, Ekkart.
Thanks, Ekkart. As of June 11, 2009, I'm taking over the development of this plugin. As a first task I've implemented a demo and download page, and I'll start implementing the feature requests soon, starting with the language files. Anyone interested in contributing their language can send me patches as per Internationalisation. Thanks. – — Luis Machuca B. 2009/06/12 06:30

do not show the Description

I installed the plugin an try it, but the description will not displayed. have a look to:

Regards, Mark W.

Fixed in the latest update. Can't believe I just missed one or two lines of code. – — Luis Machuca Bezzaza 2011/06/06 00:14
updated and it works, thx — oh-mark 2011/06/11 02:52

ADDON select language

created by — oh-mark 2011/06/11 06:18

if your language for the countdown plugin is different from the prefered language you need to modify the …/lib/plugins/countdown/syntax.php

to select the language during the admin configuration replace the original …/lib/plugins/countdown/conf/metadata.php

so we have now two ways to change the language

  1. per default in the config manager
  2. with the extented syntax: <COUNTDOWN:date|description|language>

i have an example on

new .../lib/plugins/countdown/conf/metadata.php

 * Metadata configuration for countdown plugin.
 * @license GPL 2 (
 * @author  Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
$meta['include_date'] = array('onoff');
$meta['use_today']    = array('onoff');
$meta['with_hours']   = array('onoff');
/// The two following configurations are in a beta state
$meta['business_days'] = array('onoff');
$meta['time_message'] = array('onoff');
 * Addon for Metadata configuration for countdown plugin.
 * @author Mark Wolfgruber
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
// Source:
// if not exist PHP 5 a function named scandir
if (!function_exists('scandir')) {
	function scandir($directory, $sorting_order=0) {
		if(!is_dir($directory)) {
			return false; 
		$files = array();
		$handle = opendir($directory);
		while (false !== ($filename = readdir($handle))) {
			$files[] = $filename; 
		if($sorting_order == 1) {
		} else {
		return $files;
// define countdown language directory
$countdown_lang_folder = DOKU_INC.'lib/plugins/countdown/lang';
// read countdown language directory
foreach(scandir($countdown_lang_folder) as $file) {
	if($file[0] != '.') { // do display hidden files
		if(is_dir($countdown_lang_folder.'/'.$file)) { // read directories
			$countdown_lang_folderArray[] = $file;
		} else { // read files (not needed at the moment)
			$countdown_lang_fileArray[] = $file;
$meta['language']       = array('multichoice','_choices' => $countdown_lang_folderArray);

modification 1 of the .../lib/plugins/countdown/syntax.php

    *   Plugin-Addon Language for Countdown-Plugin   
    *   this function is a copy of .../lib/plugins/syntax.php and
    *   replace the function setupLocale() for this class    
    *   only two lines are added
    *   insert function setupLocale() directly behind: class syntax_plugin_countdown extends DokuWiki_Syntax_Plugin {    
    function setupLocale() {
        if ($this->localised) return;
      global $conf;            // definitely don't invoke "global $lang"
      $path = DOKU_PLUGIN.$this->getPluginName().'/lang/';
      // don't include once, in case several plugin components require the same language file
      if ($conf['lang'] != 'en') @include($path.$conf['lang'].'/lang.php');
      // add following 2 lines 
      if ($this->getConf('countdown_language')) @include($path.$this->getConf('countdown_language').'/lang.php');
      if ($this->countdown_language) @include($path.$this->countdown_language.'/lang.php');
      $this->lang = $lang;
      $this->localised = true;

modification 2 of the .../lib/plugins/countdown/syntax.php

add in function render($mode, &$renderer, $data) behind
$description= $data[1] ? $data[1] : $this→getLang('nodesc');

        // check for new language data
        if ($data[2]) {
          if ($this->countdown_language != $data[2]) $this->localised = false;
        } else {
          if ($this->countdown_language != $this->getConf('countdown_language')) $this->localised = false;

Feature: Annual Timer

Is it possible to have it so the countdown automatically rolls over once it has reached its target so it has a new target of next year.

The idea I have in mind is to have a countdown to someones birthday, and once it has reached the end of the birthday day, it increments the target year by 1 and starts the countdown all over again.


Jaella 2012/11/23 15:44

1250 days?

Is it a way to show up how many Years, Month, Days, Hours - till to the target in 2045? There are too many days to be able to figure out when will take actually place the event…

Florin 2015/03/24

1 day miscount

In the latest version there is still a problem with day count. To fix that problem next code:

$difference = $diffseconds / 86400;

has to be replaced by the following:

$difference = ceil($diffseconds / 86400);

in plugin's syntax.php file.

Anders 2015/11/13

plugin/countdown.txt · Last modified: 2019-10-02 00:35 by florious