Extension:TimezoneConverter
Appearance
Release status: experimental |
|
|---|---|
| Implementation | Parser function |
| Author(s) | Sam Wilson (Samwilsontalk) |
| Latest version | 0.3.0 |
| MediaWiki | 1.40 |
| Database changes | No |
| Composer | samwilson/timezone-converter |
| License | GNU General Public License 3.0 or later |
| Download | GitHub: Note: |
|
$wgTimezoneConverterFormats |
|
The TimezoneConverter extension dynamically replaces dates and times in wiki pages to show them in the local timezone of the reader.
Installation
[edit]- Download and place the file(s) in a directory called
TimezoneConverterin yourextensions/folder. - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'TimezoneConverter' );
Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Usage
[edit]Call the {{#timezoneconverter}} with the following parameters:
datetime- The date to reformat, as supported by PHP. If not specified, empty, or set to
now, this is the current date and time (subject to caching). If no timezone is specified, it defaults to UTC. format- The name of the format to use, as specified in $wgTimezoneConverterFormats. If not specified, this defaults to
exact. itemProp- If specified, the value of this parameter is used as-is on the resulting
<time>...</time>element.
Examples
[edit]The following output values are a mock of the extension, and assumes that the local timezone is UTC.
{{#timezoneconverter: datetime = 2024-08-23 20:01:35 GMT+10}}→ 2024 August 23 (Friday), 10:01AM{{#timezoneconverter: datetime = 2024-08-23 20:01:35 GMT+10 | format = time}}→ 10:01AM{{#timezoneconverter: format = non-existent}}→ Invalid date format 'non-existent'. Valid formats are: time, exact, day, month, year, circa
Configuration parameters
[edit]$wgTimezoneConverterFormats- An array of arrays of possible datetime formats to be used. The keys are the name of the format to be used in
{{#timezoneconverter: format = ...}}, and the values are an array whose keys and values are:php- The format string to be used on the PHP side of things. See the documentation for DateTime::format() for more information.
js- An array to be used to format the date on the Javascript side of things. This is used as-is as the
optionsparameter forDate.toLocalString(), so see the documentation for it for more information.
| This extension is included in the following wiki farms/hosts and/or packages: This is not an authoritative list. Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm. |
