Manual talk:Timezone

Background
This article was inspired by a recent install of MediaWiki and an unsuccessful attempt to set the global Timezone to something other than UTC. After finding several broken, incomplete and incorrect pages it became apparent that a Help:Timezone page was badly needed.

The primary working method was taken from a previous article and from this wikitech email authored by Brion Vibber.

It was tested on a system with the following Versions: * MediaWiki: 1.5.6 * PHP: 4.3.11 (apache) * MySQL: 4.1.13-standard

The unconfirmed methods were tested unsuccessfully on the same system but included for further testing. Locker 09:55, 2 March 2006 (UTC)

I tried these on MediaWiki: 1.6.7, PHP: 4.3.5 (cgi), MySQL: 4.1.11-Debian_4sarge2-log, CEST time zone. By default, both logs and signatures show UTC. --Tgr 07:21, 20 July 2006 (UTC)
 * Using the primary method (with "Europe/Budapest") does absolutely nothing (except for changing the "(UTC)" text in the signature).
 * Adding Date("I") as suggested does nothing either.
 * Using only the $wgLocalTZoffset = date("Z") / 3600; line and nothing else leaves server time unchanged, and sets local time to server time +2. This gives correct CEST time in recentchanges and logs (including the deletion log; I dind't test the upload log), but still UTC in signatures.

My host probably didn't support the tz database. Primary method works fine, but I had to support time zone and DST manually. Rules for that can be found here. --Tgr 08:54, 20 July 2006 (UTC)

Use localtime
I'm using MediaWiki 1.6.6. I have tried the method mentioned in Help:Timezone and the time displayed successfully in history and recentchanges. The signature is not affected, but it always shows the correct time, regardless I change the $wgLocaltimezone or not. How is the mechanism in MediaWiki so that there are two different time functions? How to fix this? It is very critical because whenever I use the magic word, it points to the wrong time. TIA --Semut 13:18, 1 June 2006 (UTC)

Server May Crash..!! 
It works, but the server may crash.

My environment:


 * Windows XP sp2
 * AppServ 2.5.6
 * Apache: 2.2
 * PHP: 5.1.4 (apache2handler)
 * MySQL: 5.0.22-community-nt-log)
 * MediaWiki: 1.8.0

--Chlon 03:55, 16 October 2006 (UTC)

Really!
I confirm the existence of that problem. When I tried that primary method I got error: "An unhandled win32 exception occured in Apache.exe [2320]." My environment:


 * Windows XP sp1
 * Apache: 2.0.59 (Win32)
 * PHP: 5.2.0
 * MySQL: 5.0.27-community-nt
 * MediaWiki: 1.8.2

Experimentally I found out, that probably the line  is causing problem. CodeMonk 00:03, 28 November 2006 (UTC)

Confirmed
I can also confirm site failure (PHP has encountered an Access Violation at 7C81BD02) when this directive is set.


 * OS: Windows Server 2003 SP2
 * Web: Internet Information Services 6
 * PHP: 5.2.1
 * MySQL: 5.0.37-community-nt
 * MediaWiki: 1.10.1

IIS and MySQL must be restarted to clear this error.

Does not work on my MediaWiki 1.10.0 upgrade!
Used the code to no avail. It does not work since I upgraded from 1.6.10. $wgLocaltimezone = "Asia/Jerusalem"; $oldtz = getenv("TZ"); putenv("TZ=$wgLocaltimezone"); $wgLocalTZoffset = date("Z") / 3600; putenv("TZ=$oldtz");
 * 1) Versions before 1.7.0 used $wgLocalTZoffset as hours.
 * 2) After 1.7.0 offset as minutes

date_default_timezone_set("Asia/Jerusalem"); I'm lost now. Nate, 89.1.57.35 23:51, 6 June 2007 (UTC)


 * Signatures on talk pages will show correct time, Special:Recentchanges shows the same edit using wrong time! Nate, 89.1.57.35 00:08, 7 June 2007 (UTC)


 * I don't know what happened, but as I was playing with editing it, putting stuff on an off again, suddenly this agreed to work.

$wgLocaltimezone = "Asia/Jerusalem"; $oldtz = getenv("TZ"); putenv("TZ=$wgLocaltimezone"); $wgLocalTZoffset = date("Z") / 60; putenv("TZ=$oldtz");
 * 1) Versions before 1.7.0 used $wgLocalTZoffset as hours.
 * 2) After 1.7.0 offset as minutes
 * Date("Z") returns seconds, previous division by 3600 was giving hours, but as the specification says we are now to use minutes - division by 60. Funny thing is I already tried it before. Don't know why this time it caught on. Very weird. Nate, 89.1.57.35 02:06, 7 June 2007 (UTC)