手册:时区
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
- 最近更改中的时间戳
- 历史中的时间戳
Default value
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
The 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
$wgDefaultUserOptions['timecorrection'] = 'ZoneInfo|0|' . $wgLocaltimezone;
ZoneInfo
, as MediaWiki's identifier for this timezone format, handles everything dynamically, i.e., MediaWiki calculates the correct offset based on the given timezone. The configuration defines a fixed pattern that does not change no matter which timezone is set for the wiki. See the examples below.
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
- $wgLocaltimezone - Sets the timezone for the wiki.
- $wgLocalTZoffset - Sets the offset from UTC in minutes for the default timezone.