Manual:タイムゾーン

From mediawiki.org
This page is a translated version of the page Manual:Timezone and the translation is 57% complete.

個人設定で設定を行っていない利用者に指定される既定のタイムゾーン (tz) を手動で設定できます。

Default value

規定値はWebサーバーのphp.iniから読み込みます。 For documentation:

https://www.php.net/datetime.configuration#ini.date.timezone

基本的な方法

  • インストールディレクトリにある LocalSettings.php のバックアップを作成します。
  • LocalSettings.php に次のコードを追加してください
#既定のタイムゾーンを設定
$wgLocaltimezone = "Asia/Jakarta";
date_default_timezone_set( $wgLocaltimezone );
  • $LocalTimezoneとして適切な値はここにあります。 下記の例も参照してください。
$wgLocaltimezone = "UTC";
$wgLocaltimezone = "Europe/London";
$wgLocaltimezone = "Asia/Taipei";
このタイムゾーンは次の場所で使用されます。
  • ~~~~ の署名
  • 最近の更新に表示されるタイムスタンプ
  • 履歴に表示されるタイムスタンプ
このコードをLocalSettings.phpに追加するとExtension:RSS の値と競合します。 詳しくはこちらの討論ページをご覧ください。

代替方法

この方法は、先程の方法が機能しない状況で複数の利用者によって確認されました。

$wgLocaltimezone = "America/Sao_Paulo";
$dtz = new DateTimeZone($wgLocaltimezone);
$dt = new DateTime('now', $dtz);
$wgLocalTZoffset = $dtz->getOffset($dt) / 60;
unset($dtz);
unset($dt);

Alternative methods

If you just want to use the local time of your PC, you can add this line in your LocalSettings.php. This method is what MediaWiki does by default (see includes/Setup.php); it also avoids problems with daylight savings time:

$wgLocalTZoffset = date("Z") / 60;

未確認の方法

  • To use your local time zone (say NZDT) put this in LocalSettings.php
$wgLocalTZoffset = 13 * 60;

  • This example may also work
$wgLocaltimezone="Europe/Berlin";
$wgLocalTZoffset = +120;
  • In this case the primary method did not take daylight savings time into account. The example below works:
#既定のタイムゾーンを設定
$wgLocaltimezone = "Europe/Amsterdam";

#Calculate the timezone offset with UTC
$oldtz = getenv("TZ");
putenv("TZ=$wgLocaltimezone");
$wgLocalTZoffset = date("Z") / 60 + date("I") * 60;
putenv("TZ=$oldtz");

  • To make it work in 1.5.8, specify the offset in hours, so change all occurrences of '/ 60' to '/ 3600', for example.
$wgLocaltimezone = "Europe/Amsterdam";
#Calculate the timezone offset with UTC
$oldtz = getenv("TZ");
putenv("TZ=$wgLocaltimezone");
$wgLocalTZoffset = date("Z") / 3600;
putenv("TZ=$oldtz");

Combine it with the tip above to make daylight savings work.

  • This line is needed in 1.16. It applies to both anonymous and logged in users.

Note that you will need to provide the correct values if you want the zone to be selected by default in the timezone dropdown:

$wgDefaultUserOptions['timecorrection'] = 'ZoneInfo|' . (date("I") ? 120 : 60) . '|Europe/Berlin';
The methods in this section are unconfirmed and may not work properly.

Manual timezone specification

The primary method needs the server to support the 'tz' database; some non-GNU hosts don't do that. However you can supply timezone data manually - unfortunately, only "GMT0" seems to work on Windows.

使い方の例

$wgLocaltimezone = "CET-1CEST-2,M3.5.0/2,M10.5.0/2";
実際の処理は
$wgLocaltimezone = "Europe/Budapest";
または
$wgLocaltimezone = "AEST-9,M10.5.0/3,M4.1.0/3";
実際の処理は
$wgLocaltimezone = "Australia/Sydney";

For details see