Difference between revisions of "Configure timezone on a wiki"

From Organic Design wiki
(Changing the default timezone for a wiki: PHP bug fixed)
(Change source-code blocks to standard format)
 
(2 intermediate revisions by one other user not shown)
Line 6: Line 6:
 
== Changing the default timezone for a wiki ==
 
== Changing the default timezone for a wiki ==
 
The default timezone for the server should be set to UTC, so if a particular wiki needs to have a different default from that, the usual way to set it is in the ''LocalSettings.php'' file as follows:
 
The default timezone for the server should be set to UTC, so if a particular wiki needs to have a different default from that, the usual way to set it is in the ''LocalSettings.php'' file as follows:
{{code|<php>
+
<source lang="php">
 
$wgLocaltimezone="Pacific/Auckland";
 
$wgLocaltimezone="Pacific/Auckland";
 
putenv("TZ=$wgLocaltimezone");
 
putenv("TZ=$wgLocaltimezone");
$wgLocalTZoffset = date("Z") / 3600;
+
$wgLocalTZoffset = date("Z") / 60;
</php>}}
+
</source>
 
 
== Signatures ==
 
The way the signature timestamps work in MediaWiki is not based on the users preferences, but is instead a global setting so that discussions and other communications don't have differing timezones. However, if as for the NZST problem the ''$wgLocalTZoffset'' has been set, then this will not apply to signatures, and the only way to fix this is with a code-base hack :-(
 
 
 
The following adjustments can be made to the signature rendering code in ''includes/parser/Parser.php'' at about line 3800. The ''$tz'' variable must be calculated from the local timezone, and the normal condition must be removed by prepending a '''0 &&''' as follows:
 
{{code|<pre>
 
$tz = wfMsgForContent( 'timezone-utc' ); # this is no longer done
 
$tz = date( 'T', );                      # use the local zone instead
 
if ( 0 && isset( $wgLocaltimezone ) ) {  # this condition is nulled out with the preceding 0 &&
 
</pre>}}
 
  
 
== See also ==
 
== See also ==
 
*[[MW:Manual:$wgLocaltimezone]]
 
*[[MW:Manual:$wgLocaltimezone]]
 
*[[MW:Manual:$wgLocalTZoffset]]
 
*[[MW:Manual:$wgLocalTZoffset]]

Latest revision as of 18:11, 22 May 2015

Procedure.svg Configure timezone on a wiki
Organic Design procedure

Changing the default timezone for a wiki

The default timezone for the server should be set to UTC, so if a particular wiki needs to have a different default from that, the usual way to set it is in the LocalSettings.php file as follows:

$wgLocaltimezone="Pacific/Auckland";
putenv("TZ=$wgLocaltimezone");
$wgLocalTZoffset = date("Z") / 60;

See also