DateTimePlugin
<--
Contributions to this plugin are appreciated. Please update the plugin page at
http://twiki.org/cgi-bin/view/Plugins/DateTimePlugin or provide feedback at
http://twiki.org/cgi-bin/view/Plugins/DateTimePluginDev .
If you are a TWiki contributor please update the plugin in the SVN repository.
-->
Display date and time with formatting options and localized dates
Introduction
This plugin is an extension of the TWiki variable GMTIME{"format"} (that only allows to show the current date and time).
DateTimePlugin lets you show any date and time before or after 'now', and it will return any part of a date such as the month name.
With DateTimePlugin you can write:
In five days will be: %DATETIME{incdays="5"}% and will have a always coherent phrase.
Date and time are displayed in GMT because of the way {DisplayTimeValues} configuration parameter is set. There is no way to specify a time zone in which date and time are displayed.
Syntax Rules
Use %DATETIME{}% to show the current date and time in default date format (as set in configure).
For more options use: %DATETIME{"format" <optional parameters>}%
Parameters
Parameter |
Description |
Example |
"..." or format="..." |
Format of date string; see GMTIME{"format"} for formatting variables |
%DATETIME{"$wday"}% |
date="..." |
Any date in one of the following formats: Default TWiki format 31 Dec 2001 - 23:59 TWiki format without time (defaults to 00:00 ) 31 Dec 2001 Date seperated by '/', '.' or '-', time with '.' or ':' Date and time separated by ' ', '.' and/or '-' 2001/12/31 23:59:59 2001.12.31.23.59.59 2001/12/31 23:59 2001.12.31.23.59 2001-12-31 23:59 2001-12-31 - 23:59 ISO format 2001-12-31T23:59:59 ISO dates may have a timezone specifier, either Z or a signed difference in hh:mm format. For example: 2001-12-31T23:59:59+01:00 2001-12-31T23:59Z In formats other than ISO, GMT time zone is always assumed. Timestamp (seconds from the epoch) 1009843199 Note: will not handle dates before 1970! |
%DATETIME{date="2001/12/31"}% |
incdays="..." |
Increase the date by any number of days (may be a negative number) |
%DATETIME{date="31 Dec 2001" incdays="1"}% |
inchours="..." |
Increase the date by any number of hours (may be a negative number) |
%DATETIME{date="31 Dec 2001 - 07:00" format="$hours" inchours="-1"}% |
incminutes="..." |
Increase the date by any number of minutes (may be a negative number) |
%DATETIME{date="31 Dec 2001" format="$minutes" incminutes="15"}% |
incseconds="..." |
Increase the date by any number of seconds (may be a negative number) |
%DATETIME{date="31 Dec 2001" format="$seconds" incseconds="20"}% |
timezone="..." |
Specify the time zone in which the result is displayed. Please note that this parameter affects only display. It doesn't affect how the date parameter value is evaluated. As of July 2015, this papameter requires TWiki core downloaded from http://svn.twiki.org to work |
%DATETIME{"$hour:$min $tz" timezone="America/New_York"}% |
Formatting parameters
See GMTIME{"format"} for general date and time formatting parameters to pass to format . DateTimePlugin supports the following additional paramters:
Parameter |
Description |
Example |
$i_month |
The localized short name of the month. |
Ago |
$lmonth |
The English long name of the month. |
July |
$i_lmonth |
The localized long name of the month. |
Julho |
$i_wday |
The summarized internationalized name of the day of the week. |
Qua |
$lwday |
The English long name of the day of the week. |
Wednesday |
$i_lwday |
The localized long name of the day of the week. |
Quarta-feira |
Overview of all formatting variables
$seconds |
27 |
$minutes |
04 |
$hours |
00 |
$day |
03 |
$wday |
Fri |
$i_wday |
Fri |
$i_lwday |
Friday |
$dow |
5 |
$week |
5 |
$month |
Feb |
$mo |
02 |
$i_month |
Feb |
$i_lmonth |
February |
$year |
2023 |
$ye |
23 |
$tz |
GMT |
$iso |
2023-02-03T00:04Z |
$rcs |
2023/02/03 00:04:27 |
$http |
Fri, 03 Feb 2023 00:04:27 GMT |
$epoch |
1675382667 |
Examples
Yesterday was %DATETIME{"$day $month $year" incdays="-1"}%
results in:
Yesterday was Thursday, 02 Feb 2023
One week from now is %DATETIME{"$wday, $day $month $year" incdays="7"}%
results in:
One week from now is Fri, 10 Feb 2023
To create time-based topics:
%DATETIME{
"Create TODO topic for tomorrow: [[ToDo$year$mo$day]] ($lwday, $day $lmonth)"
incdays="1"
}%
results in:
Create TODO topic for tomorrow: ToDo20230204 (Saturday, 04 February)
Limitations
Due to date handling in Perl, DateTimePlugin cannot handle dates earlier than 1970.
Localization
Localized dates are read from configure.
Plugin Installation Instructions
Note: You do not need to install anything on your browser to use this plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running.
<--/twistyPlugin twikiMakeVisibleInline-->
- Download the ZIP file from the Plugin web (see below)
- Unzip
DateTimePlugin.zip in your twiki installation directory. Content: File: | Description: | lib/TWiki/Plugins/DateTimePlugin.pm | Plugin Perl module | data/TWiki/DateTimePlugin.txt | Plugin topic | data/TWiki/VarDATETIME.txt | Variable documentation topic |
- Visit
configure in your TWiki installation, and enable the plugin in the {Plugins} section.
- Debugging: Visit configure and set
{DateTimePlugin}{Debug} to 1.
<--/twistyPlugin-->
Plugin Info
- One line description, is shown in the TextFormattingRules topic:
- Set SHORTDESCRIPTION = Display date and time with formatting options and localized dates
<--/twistyPlugin twikiMakeVisibleInline--> <--/twistyPlugin-->
Related Topics: VarDATETIME, TWikiPlugins, DeveloperDocumentationCategory, UserDocumentationCategory |