component1Add my vote for this tag date_time3Add my vote for this tag create new tag
, view all tags


Display time difference in a human readable way


This plugin is inspired by the WordPress TimeSince plugin. It which can be used to display a time difference in a human readable way, for instance to tell you that a topic has been published "2 days, 3 hours ago".

There are some problems with the original TimeSince plugin for WordPress. For example, it was only able to display a time diff with at most two expressions: "1day, 2hours ago" or "1 week ago" but not "1 day, 2 hours and 3 minutes". It even displays only one time expression if the difference does not occure in two adjacent time units (time units are year, month, week, day, hour, minute). If a time interval differs in week and hour the TimeSince WP plugin will only display the week difference and not the hours as week and hour are not adjacent. This is fixed in the TimeSincePlugin for TWiki. Several other parameters have been added to give a finer control of the format and the information displayed.

Syntax Rules

%TIMESINCE%, %TIMESINCE{[[from]="..."] [to="..."]}%

Without arguments the time since the current topic has been created will be displayed.

Argument Description
from="<time-experssion>" the starting time point, if ommited the current time
to="<time-expression>" the ending timepoint, if ommited the current time
units="1...7" number of time units to display, default 2; (example units="3": 2 months, 1 day and 3 minutes)
seconds="on,off" switch on/off second precision
null="<format-string>" to be displayed if the tim difference is null; defaults to "about now"
format="<format-string>" format of the output, defaults to "$time", other usefull settings format="$time ago", format="replied $time later", "format="$time after the incident"
negformat="<format-string>" use this format string if the time difference is negative

Time expressions can be specified in any of the following format:

  • 31 Dec 2001 - 23:59 (TWiki date)
  • 31 Dec 2001
  • 2001/12/31 23:59:59 (RCS date)
    also -, . instead of / in date, also . instead : in time
  • 2001/12/31 23:59
  • 2001/12/31
  • 2001-12-31T23:59:59Z (ISO date)
  • 2001-12-31T23:59:59+01:00
  • 2001-12-31T23:59Z
  • 2001-12-31T23:59+01:00
  • epoch seconds

Format strings may contain the following:

  • $time expands to the calculated time difference
  • $percnt$ expands to a % char
  • $dollar$ expands to a $ char
  • $n expands to a linefeed
  • $t expands to a tab space
  • $nop expands to the empty string


You type You get (simulated) You get (if installed)
%TIMESINCE% 1 day, 3 hours %TIMESINCE%
%TIMESINCE{format="topic was created $time ago" null="topic has just now been saved" units="4" }% topic was created 1 day, 3 hours, 8 minutes ago %TIMESINCE{format="topic was created $time ago" null="topic has just now been saved" units="4"}%
%TIMESINCE{"11 Sep 2001 - 8:45" units="7" seconds="on"}% 4 years, 2 months, 2 days, 5 hours, 50 minutes, 16 seconds %TIMESINCE{"11 Sep 2001 - 8:45" units="7" seconds="on"}%
%TIMESINCE{from="1955/04/18" to="1979-03-14" units="3"}% 23 years, 11 months, 6 days %TIMESINCE{from="1955/04/18" to="1979-03-14" units="3"}%

Plugin Installation Instructions

  • Download the ZIP file from the Plugin Home (see below)
  • Unzip it in your twiki installation directory. Content:
    File: Description:
    data/TWiki/TimeSincePlugin.txt plugin topic
    lib/TWiki/Plugins/TimeSincePlugin.pm plugin perl module
    lib/TWiki/Plugins/TimeSincePlugin/Core.pm plugin core
  • Visit configure in your TWiki installation, and enable the plugin in the {Plugins} section.

Plugin Info

Plugin Author: TWiki:Main.MichaelDaum
Copyright: © 2005-2008 Michael Daum http://michaeldaumconsulting.com,
© 2005-2010 TWiki:TWiki.TWikiContributor
License: GPL (GNU General Public License)
Plugin Version: 19277 (2010-07-27)
Change History:  
2010-07-27: TWikibug:Item6530 - doc fixes; changing TWIKIWEB to SYSTEMWEB
03 Jan 2008: improved parsing time formats
13 Oct 2006: added negformat parameter
31 Aug 2006: added NO_PREFS_IN_TOPIC
27 Apr 2006: added lazy compilation
11 Nov 2005: Initial version
TWiki Dependency: $TWiki::Plugins::VERSION 1.1
CPAN Dependencies: CPAN:Time::Local
Other Dependencies: none
Perl Version: 5.005
TWiki:Plugins.Benchmark: GoodStyle nn%, FormattedSearch nn%, TimeSincePlugin nn%
Plugin Home: http://twiki.org/cgi-bin/view/Plugins/TimeSincePlugin
Feedback: http://twiki.org/cgi-bin/view/Plugins/TimeSincePluginDev
Appraisal: http://twiki.org/cgi-bin/view/Plugins/TimeSincePluginAppraisal

Related Topics: TWikiPlugins, DeveloperDocumentationCategory, UserDocumentationCategory

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatmd5 TimeSincePlugin.md5 r9 r8 r7 r6 r5 manage 0.2 K 2010-07-27 - 08:38 PeterThoeny  
Compressed Zip archivetgz TimeSincePlugin.tgz r9 r8 r7 r6 r5 manage 6.6 K 2010-07-27 - 08:38 PeterThoeny  
Compressed Zip archivezip TimeSincePlugin.zip r10 r9 r8 r7 r6 manage 9.1 K 2010-07-27 - 08:38 PeterThoeny  
Unknown file formatEXT TimeSincePlugin_installer r3 r2 r1 manage 3.4 K 2010-07-27 - 08:38 PeterThoeny  
Edit | Attach | Watch | Print version | History: r22 < r21 < r20 < r19 < r18 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r22 - 2013-10-16 - PeterThoeny
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2015 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.