Jump to: navigation, search

The default Timezone (tz) for users who have not specified a custom offset may be configured manually.

Primary Method[edit | edit source]

  • Create a backup copy of the LocalSettings.php file found in your install directory
  • Edit LocalSettings.php and add the following code:
#Set Default Timezone
$wgLocaltimezone = "Asia/Jakarta";
date_default_timezone_set( $wgLocaltimezone );
$wgLocaltimezone = "UTC";
$wgLocaltimezone = "Europe/London";
$wgLocaltimezone = "Asia/Taipei";

Note: This timezone will be used in:

  • ~~~~ signatures
  • timestamps in recentchanges
  • timestamps in history

Note: Adding this code to the LocalSettings.php conflicts with the RSS Feed dates in Extension:RSS. See the Discussion page of Extension:RSS for more information

Alternative Method[edit | edit source]

This method has been confirmed by multiple users in situations where the primary method has not worked.

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

Alternative Methods[edit | edit source]

If you just want to use the local time of your PC, you can just 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 saving time:

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

Unconfirmed Methods[edit | edit source]

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

  • This example may also work great
$wgLocalTZoffset = +120;
  • In my case the primary method did not take daylight saving time into account. The next example works for me:
#Set Default Timezone
$wgLocaltimezone = "Europe/Amsterdam";

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

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

I cannot test daylightsavings right now, so you probably have to combine it with the tip above to make that work.

  • This line is all I need 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';

Note: The methods in this section are unconfirmed and may not work properly.

Manual Timezone Specification[edit | edit source]

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.

E.g. use

$wgLocaltimezone = "CET-1CEST-2,M3.5.0/2,M10.5.0/2";
instead of
$wgLocaltimezone = "Europe/Budapest";
$wgLocaltimezone = "AEST-9,M10.5.0/3,M4.1.0/3";
instead of
$wgLocaltimezone = "Australia/Sydney";

For details see

Language: English  • Ελληνικά • français • 日本語