01227: Changes to "InitialSetupTasks" for timezone support

Summary: Changes to "InitialSetupTasks" for timezone support
Created: 2010-09-27 10:34
Status: Closed, done
Category: Documentation
From: Steve
Assigned:
Priority: 3
Version: 2.2.18
OS: Ubuntu Linux/Apache/PHP 5.2.4

Description: InitialSetupTasks shows the following for adding timezone support:

 putenv("TZ=EST5EDT");
 $TimeFmt = '%B %d, %Y, at %I:%M %p EST';

PHP 5.1 or later uses date_default_timezone_set, so the putenv approach doesn't work on some systems. Also, there is a macro (%Z) for the timezone.

I recommend replacing these two lines with the following and adding a warning that users on PHP 4 or 5.0 need to use putenv.

 date_default_timezone_set('EST5EDT');
 $TimeFmt = '%B %d, %Y, at %I:%M %p %Z';

date_default_timezone_set works for me, while putenv("TZ=...") does not (php 5.2.15, pmwiki 2.2.21).
I don't know much of how it works, but moving putenv("TZ=...") out of config.php, e.g. in the wrapper for pmwiki.php works too.

Also isn't EST5EDT deprecated? (http://php.net/manual/en/timezones.others.php). Some of the time zones listed in Cookbook.ChangeTimeFormat e.g. CET-1CEST, are not present in the list of supported timezones from the php website (http://php.net/manual/en/timezones.php), and they don't work for me. A link to said list in InitialSetupTasks would be handy. They look like the time zones in the glibc-zoneinfo database, you could just say to look in /usr/share/zoneinfo or similar path in your local box lo find the right one.

Array
(
    [post_max_size] => 64M
    [$_POST keys] => 
    [$_REQUEST keys] => n
    [$_SERVER] => Array
        (
            [CONTEXT_DOCUMENT_ROOT] => /home/pmwiki/public_html
            [CONTEXT_PREFIX] => 
            [DOCUMENT_ROOT] => /home/pmwiki/public_html
            [GATEWAY_INTERFACE] => CGI/1.1
            [HTTPS] => on
            [HTTP_ACCEPT] => */*
            [HTTP_ACCEPT_ENCODING] => gzip, br, zstd, deflate
            [HTTP_COOKIE] => PHPSESSID=ogbl30a74v2n1ead8o2ns9cd57; imstime=1777550358
            [HTTP_HOST] => www.pmwiki.org
            [HTTP_USER_AGENT] => Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
            [HTTP_X_HTTPS] => 1
            [PATH] => /bin:/usr/bin
            [PHP_INI_SCAN_DIR] => /opt/cpanel/ea-php70/root/etc:/opt/cpanel/ea-php70/root/etc/php.d:.
            [QUERY_STRING] => n=PITS%2f01227
            [REDIRECT_HTTPS] => on
            [REDIRECT_QUERY_STRING] => n=PITS%2f01227
            [REDIRECT_SCRIPT_URI] => https://www.pmwiki.org/wiki/PITS/01227
            [REDIRECT_SCRIPT_URL] => /wiki/PITS/01227
            [REDIRECT_SSL_TLS_SNI] => www.pmwiki.org
            [REDIRECT_STATUS] => 200
            [REDIRECT_UNIQUE_ID] => afNEKmp2_NWDT7vuXhSYCQAAAA4
            [REDIRECT_URL] => /wiki/PITS/01227
            [REMOTE_ADDR] => 216.73.216.25
            [REMOTE_PORT] => 19707
            [REQUEST_METHOD] => GET
            [REQUEST_SCHEME] => https
            [REQUEST_URI] => /wiki/PITS/01227
            [SCRIPT_FILENAME] => /home/pmwiki/public_html/index.php
            [SCRIPT_NAME] => /index.php
            [SCRIPT_URI] => https://www.pmwiki.org/wiki/PITS/01227
            [SCRIPT_URL] => /wiki/PITS/01227
            [SERVER_ADDR] => 23.254.203.248
            [SERVER_ADMIN] => webmaster@pmwiki.org
            [SERVER_NAME] => www.pmwiki.org
            [SERVER_PORT] => 443
            [SERVER_PROTOCOL] => HTTP/1.1
            [SERVER_SIGNATURE] => 
            [SERVER_SOFTWARE] => Apache
            [SSL_TLS_SNI] => www.pmwiki.org
            [TZ] => America/Los_Angeles
            [UNIQUE_ID] => afNEKmp2_NWDT7vuXhSYCQAAAA4
            [PHP_SELF] => /index.php
            [REQUEST_TIME_FLOAT] => 1777550378.9891
            [REQUEST_TIME] => 1777550378
            [argv] => Array
                (
                    [0] => n=PITS%2f01227
                )

            [argc] => 1
        )

)