%LOCALTIME%
or %LOCALTIME{…}%
%LOCALTIME%
expands to the current date and time using the default format, time zone, and locale
%LOCALTIME{…}%
expands to a date and time allowing the default behavior to be overridden according to any parameters supplied
Parameter: | Description: | Default |
---|---|---|
"timezone" | The name of the desired time zone such as "Asia/Tokyo" or "CST6CDT" or "UTC" | "UTC" |
datetime="…" | The date and time to display. This parameter is assumed to be in UTC unless it contains a time zone specifier.
Notes:
| Current time |
format="…" | The format specifier string defining how to display the date and/or time | "$longdate" |
locale="…" | The locale to use when displaying the date/time | "en_US" |
Parameter: | Description: | Deprecated |
---|---|---|
dateGMT="…" | The same as datetime , use datetime instead | Since 1.1 |
fromtopic="…" | The web.topic from which to get the value of the TIMEZONE variable, use the preference setting LOCALTIMEPLUGIN_TIMEZONE instead | Since 1.1 |
Token: | Unit: | Example |
---|---|---|
$seconds | seconds | 59 |
$minutes | minutes | 59 |
$hours | hours | 23 |
$day | day of month | 31 |
$wday | day of the Week (Sun, Mon, Tue, Wed, Thu, Fri, Sat) | Thu |
$dow | day of the week (Sun = 0) | 2 |
$week | number of week in year (ISO 8601) | 34 |
$month | short name of month | Dec |
$mo | 2 digit month | 12 |
$year | 4 digit year | 1999 |
$ye | 2 digit year | 99 |
$tziso | time zone as offset from UTC ±HHMM | -0500 |
$tz | time zone identifier | UTC |
$epoch | seconds since 1970-01-01T00:00:00Z | 1057159140 |
$iso | ISO format timestamp | 1999-12-31T23:59:59-0500 |
$rcs | RCS format timestamp | 1999/12/31 23:59:59 |
$http | RFC 2616 timestamp, same as $email | Fri, 31 Dec 1999 23:59:59 EST |
$email | RFC 822/1123 timestamp, same as $http | Fri, 31 Dec 1999 23:59:59 EST |
$rfc | RFC 2822/5322 timestamp | Fri, 31 Dec 1999 23:59:59 -0500 |
$longdate | Site default date format followed by " - HH:MM" | 31 Dec 1999 - 23:59 |
$sec
for $seconds
)
$second
, $minute
, and $hour
are also accepted
format
also accepts strftime
format specifiers. However, since the percent sign is significant to Foswiki, the $percnt
token must be used instead of an actual percent sign. For example: the default locale timestamp specifier %c
would be specified as $percntc
in the format string.
If the plugin has been successfully installed, the following examples will show several ways to manipulate the display of dates and times using the plugin.
Current default settings:You want: | You type: | You get: |
---|---|---|
Current time: | %LOCALTIME% |
05 Sep 2024 - 16:05 |
Current time in Tokyo: | %LOCALTIME{"Asia/Tokyo"}% |
06 Sep 2024 - 01:05 |
Current time in US Central Time Zone: | %LOCALTIME{"CST6CDT"}% |
05 Sep 2024 - 11:05 |
Current time in Internet format: | %LOCALTIME{format="$rfc"}% |
Thu, 05 Sep 2024 16:05:25 +0000 |
Current time in Paris, France: | %LOCALTIME{"Europe/Paris" locale="fr_FR" format="$rfc"}% |
Thu, 05 Sep 2024 18:05:25 +0200 |
2006-04-05T15:43:50Z in Sydney, Australia |
%LOCALTIME{"Australia/Sydney" datetime="2006-04-05T15:43:50Z"}% |
06 Apr 2006 - 01:43 |
|
%LOCALTIME{"Australia/Sydney" datetime="Sun, 28 Mar 2010 05:58:38 -0500 (CDT)" format="$http"}% |
Sun, 28 Mar 2010 21:58:38 AEDT |
Setting | Description | Default |
---|---|---|
DATEFORMAT | The default output format specifier to use when formatting dates and/or times | $longdate |
DEBUG | Enable/disable logging of debug traces to the Foswiki Debug Log | off |
LOCALE | The default locale to use when formatting dates and/or times | en_US |
TIMEZONE | The default time zone to use when interpreting the value of the datetime parameter when no time zone is provided. |
UTC |
Use TML assignment statements in the body content or the topic preferences of a topic to set the value of a plugin preference. You can copy one or more of the example assignment statements below to set the desired preference value.
* Set LOCALTIMEPLUGIN_DATEFORMAT = $longdate * Set LOCALTIMEPLUGIN_DEBUG = off * Set LOCALTIMEPLUGIN_LOCALE = en_US * Set LOCALTIMEPLUGIN_TIMEZONE = UTC
You do not need to install anything in the browser to use this extension. The following instructions are for the site administrator who installs the extension on the server.
You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.
Open configure, and open the "Extensions" section. Use "Find More Extensions" to get a list of available extensions. Select "Install".
If you have any problems, or if the extension isn't available inconfigure
, then you can still install manually from the command-line. See http://foswiki.org/Support/ManuallyInstallingExtensions for more help.
LocalTimePlugin makes use of the following configuration settings which may be set to adapt the plugin to work in your particular environment.
Setting | Description |
---|---|
{UseLocale} |
Enable/Disable use of locales for the site |
{Site}{Locale} |
The default locale for the site. This setting will be ignored if {UseLocale} is disabled. |
{DefaultDateFormat} |
The default date format for the site |
{Tools}{perlCmd} |
The path to the Perl interpreter if it isn't on the default path |
{Plugins}{LocalTimePlugin}{perlCmd} |
The path to the Perl interpreter if it isn't on the default path. If present, overrides the setting of {Tools}{perlCmd} |
Current time (UTC): | 05 Sep 2024 - 16:05 |
Current time (Asia/Tokyo): | 06 Sep 2024 - 01:05 |
Current time (CST6CDT): | Thu, 05 Sep 2024 11:05:25 -0500 |
2010-03-24T12:34:56Z: | 2010-03-24T12:34:56+0000 |
File: | Description: |
---|---|
data/System/LocalTimePlugin.txt |
Plugin documentation topic |
data/System/VarLOCALTIME.txt |
Syntax summary for the LOCALTIME macro |
lib/Foswiki/Plugins/LocalTimePlugin.pm |
Plugin module |
lib/Foswiki/Plugins/LocalTimePlugin/Config.spec |
Config template |
Author: | TWiki:Main.NathanOllerenshaw, Foswiki:Main.SvenDowideit, & Foswiki:Main.BryanThale | ||||||||||||
Copyright: | © 2010, Foswiki Contributors | ||||||||||||
License: | GPL (GNU General Public License, Version 3) | ||||||||||||
Release: | 1.1.1 | ||||||||||||
Version: | 7117 (2010-04-07) | ||||||||||||
Home: | Foswiki:Extensions.LocalTimePlugin | ||||||||||||
Support: | Foswiki:Support.LocalTimePlugin | ||||||||||||
Dependencies: |
|
||||||||||||
Change History: | |||||||||||||
07 Apr 2010 (1.1.1): | Foswikitask:Item8853 - Remove leak of server path information in error messages and require Foswiki Plugin API v2.0+ | ||||||||||||
03 Apr 2010 (1.1): | Foswikitask:Item8805 - Correct handling of parameters and formatting tokens Foswikitask:Item8806 - Change default time zone to UTC, add datetime parameter, deprecate fromtopic and dateGMT parametersFoswikitask:Item8757 - Add support for mod_perl2 Foswikitask:Item8807 - Add support for user locale Foswikitask:Item1854 - Use published Plugin API calls |
||||||||||||
20 Feb 2009 (1.0): | port to Foswiki | ||||||||||||
05 Mar 2006 (Dakar): | SvenDowideit@WikiRing.com - updated to use registerHandler, added format= and dateGMT parameters | ||||||||||||
02 Jul 2003: | Initial version |