It's better when it's simple

User Tools

Site Tools


Definition Localdate

Compatible with DokuWiki

No compatibility info given!

plugin Display date/time in client's regional format

Last updated on

The missing download url means that this extension cannot be installed via the Extension Manager. Please see Publishing a Plugin on Recommended are public repository hosts like GitHub, GitLab or Bitbucket.

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Tagged with !experimental, date, time



With this plugin the syntax of DokuWiki is extended to allow display of local date on client machine. The syntax to use this plugin is:


Plugin will use JavaScript to display date/time on client's side using regional date setting. For example using


will display in some browser June 16th, 2005 00:00 or 05/07/16 00:00 AM on another, etc., depending on client's regional setting.


Put the following PHP file in /lib/plugins/localdate/syntax.php.

 * Local-date Plugin: outputs date in client's locale. Syntax is <date>year,month,day[,hour,minute]</date>,
 * output is something like "January 01th, 2005 00:00", or "05/01/01 03:45 PM" depending on user's regional settings.
 * Time is not mandatory. If not specified, '00:00' will be displayed.
 * Uses JavaScript function Date.toLocaleString().
 * Issues: It always outputs time as well, sometimes we don't want this. No solution yet.
 * @license    GPL 2 (
 * @author     pavel Vitis <pavel [dot] vitis [at] seznam [dot] cz>
 * All DokuWiki plugins to extend the parser/rendering mechanism
 * need to inherit from this class
class syntax_plugin_localdate extends DokuWiki_Syntax_Plugin {
     * return some info
    function getInfo(){
        return array(
            'author' => 'Pavel Vitis',
            'email'  => '',
            'date'   => '2005-07-27',
            'name'   => 'Local-date Plugin',
            'desc'   => 'Prints date in client\'s locale format',
            'url'    => '',
     * Constructor - adds allowed modes
    function syntax_plugin_localdate(){
        global $PARSER_MODES;
        $this->allowedModes = array_merge (
     * What kind of syntax are we?
    function getType(){
        return 'substition';
     * Where to sort in?
    function getSort(){
        return 108;
    * Connect pattern to lexer
    function connectTo($mode) {
    function postConnect() {
     * Handle the match
    function handle($match, $state, $pos, &$handler){
        return array($match, $state);
     * Create output
    function render($mode, &$renderer, $data) {
        if($mode == 'xhtml'){
            if ($data[1] == DOKU_LEXER_ENTER){
                $renderer->doc .= 
		    "\x3Cscript language=\"javascript\"\x3E\n".
		    "document.write((new Date(";
            } else if ($data[1] == DOKU_LEXER_UNMATCHED){
        	$dateStr = trim($data[0]);
        	if (strlen($dateStr > 0)) {
        	    $elements = explode(",", $dateStr);
        	    if (count($elements)>2) {
                	$renderer->doc .= $elements[0]; //year
                	$renderer->doc .= ",".($elements[1]*1-1); //month
                	$renderer->doc .= ",".$elements[2]; //day
          		if (count($elements)>=5) {
                    	    $renderer->doc .= ",".$elements[3]; //hour
                    	    $renderer->doc .= ",".$elements[4]; //minute
            } else if ($data[1] == DOKU_LEXER_EXIT){
                $renderer->doc .= 
            return true;
        return false;
//Setup VIM: ex: et ts=4 enc=utf-8 :


You can see this in action on my site
Pavel Vitis

A couple of things. Are you sure this plugin is of type formatting, it seems more like protected or substition to me. Does the <date> syntax allow other DokuWiki markup to be nested within it? Your description at the top seems to say not, however your plugin says it allows other substition, formatting & disabled modes within it. That implies <date>**2005**,//9//,%%7%%</date> is legitimate markup. — ChrisS 2005-07-27
Yes that's right. I fixed it in above code. As well month has been displayed incorrectly, I forgot to subtract 1 from month, since JavaScript is numbering months starting from 0. Should be OK now. Thanks for your tip.
Pavel Vitis
You have left 'substition' as an allowed mode type. I don't think there should be any. If there is any markup for a 'substition' mode (e.g. smiley or acronym) your plugin won't get to see that data. Your plugin won't get to see the data that belongs to any other mode, not before or after that mode processes it. — ChrisS 2005-07-28
plugin/localdate.txt · Last modified: 2018-06-04 23:21 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki