Extension:TimezoneConverter
![]() Release status: experimentalCategory:Experimental extensions |
|
---|---|
Implementation | Parser functionCategory:Parser function extensions |
Author(s) | Sam Wilson (Samwilsontalk) |
Latest version | 0.2.0 |
MediaWiki | 1.36Category:Extensions with manual MediaWiki version |
Database changes | No |
Composer | samwilson/timezone-converter Category:Extensions supporting Composer |
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
- Download and place the file(s) in a directory called
TimezoneConverter
in 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
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
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
$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
options
parameter 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. |
Category:All extensions
Category:Experimental extensions
Category:Extensions in GitHub version control
Category:Extensions included in Miraheze
Category:Extensions not in ExtensionJson
Category:Extensions supporting Composer
Category:Extensions with manual MediaWiki version
Category:Extensions without a compatibility policy
Category:Extensions without an image
Category:GPL licensed extensions
Category:ParserFirstCallInit extensions
Category:Parser function extensions