This page is a translated version of the page Manual:Timezone and the translation is 36% complete.
Outdated translations are marked like this.

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
  • 最近更改中的时间戳
  • 历史中的时间戳

默认值

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

Local timezone

  • 将$Localtimezone的值设置为适当的值(您可以在这里找到)。
Example
$wgLocaltimezone = "Australia/Sydney";

Timezone offset

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

Timecorrection

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

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