Jump to content

Manual:Timezone

From mediawiki.org

This page is about configuring the default Timezone (tz) for users who have not specified a custom offset in their preferences. The timezone is used in the following places:

  • signatures
  • timestamps in recentchanges
  • timestamps in history

Default value

[edit]

The default value is taken from the web server configuration in the "php.ini" file. See the documentation on PHP.net for the date.timezone configuration option

Configuration

[edit]

Local timezone

[edit]

The local timezone is set with the configuration parameter $wgLocaltimezone . Possible values are documented in the list of tz database zones.

Example
$wgLocaltimezone = "Australia/Sydney";

Timezone offset

[edit]

Defining the timezone offset with configuration parameter $wgLocalTZoffset is usually not required.

Timecorrection

[edit]

A user's time correction is set with configuration parameter $wgDefaultUserOptions and preference name "timecorrection". It respects the calculated offset and timezone dynamically. It applies to anonymous users and new user accounts which have not changed their preferences.

Value:

The current default value is:

$wgDefaultUserOptions['timecorrection'] = 'ZoneInfo|0|' . $wgLocaltimezone;

There are two forms of the value, one a structured syntax for defining three different types of offset, and one legacy form that should no longer be used.

The first is a pipe separated tuple of a maximum of 3 fields:

  • Field 1 is the type of offset definition: System, Offset, or ZoneInfo
  • Field 2 is the offset in minutes from UTC (ignored for System type, and for ZoneInfo if a timezone name is given)
  • Field 3 is a timezone name from the tz database (only required for ZoneInfo type)

Examples:

  • System — Use the $wgLocaltimezone.
  • System|60 — Use the $wgLocaltimezone (the 60 is ignored).
  • Offset|-480 — Constant offset of -8 hours from UTC, ignoring DST.
  • ZoneInfo|60|Europe/Amsterdam — Set to the Europe/Amsterdam timezone, changing as required for DST. The 60 is ignored.

The second form provides an offset in hours and minutes, and is now only used by the preferences input (although these values may still be present in the database of older MediaWiki installations, do not use this form when setting $wgDefaultUserOptions).

Examples:

  • -8:00 — A fixed offset of -8 hours.
  • 5:30 — A fixed offset of 5½ hours (e.g. Indian time).

Examples

[edit]
Australia/Sydney
$wgLocaltimezone = 'Australia/Sydney';
$wgDefaultUserOptions['timecorrection'] = 'ZoneInfo|0|' . $wgLocaltimezone;
America/Buenos_Aires
$wgLocaltimezone = 'America/Buenos_Aires';
$wgDefaultUserOptions['timecorrection'] = 'ZoneInfo|0|' . $wgLocaltimezone;
Europe/Berlin
$wgLocaltimezone = 'Europe/Berlin';
$wgDefaultUserOptions['timecorrection'] = 'ZoneInfo|0|' . $wgLocaltimezone;

See also

[edit]