Extension:TimeConvert

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
TimeConvert
Release status: beta
Implementation Parser function
Description Provides a parser function and Scribunto Lua library to convert a time to a different time zone
Author(s) dlhtalk
MediaWiki 1.18+
PHP 5.2+
Database changes No
License MIT License
Download
README
Translate the TimeConvert extension if it is available at translatewiki.net
Check usage and version matrix.

The TimeConvert extension provides a parser function and Scribunto Lua library to convert a time to a different time zone.

Examples[edit]

{{#timeconvert:2014-01-01 13:00 GMT|America/New_York}}       => 2014-01-01T08:00:00-0500
{{#timeconvert:2014-01-01 13:00 GMT|America/New_York|g:i A}} => 8:00 AM
{{#timeconvert:2014-01-01 8:00 AM EST|Etc/GMT|G:i}}          => 13:00

Documentation[edit]

{{#timeconvert:date time|time zone|format}}

Scribunto Lua Library[edit]

TimeConvert provides a Scribunto library, mw.ext.timeconvert. Examples:

local timeconvert = mw.ext.timeconvert.timeconvert
timeconvert("2014-01-01 13:00 GMT", "America/New_York")          => "2014-01-01T08:00:00-0500"
timeconvert("2014-01-01 13:00 GMT", "America/New_York", "g:i A") => "8:00 AM"
timeconvert("2014-01-01 8:00 AM EST", "Etc/GMT", "G:i")          => "13:00"

Installation[edit]

  • Download and place the file(s) in a directory called TimeConvert in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/TimeConvert/TimeConvert.php";
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.