× Warning! This forum is in archival status. New contributions may not work.
Better working with Daylight Saving Time (DST)
  • I have problem with original settings, because can't set Country for time zone. I must two time in year change timezone setting because DST.

    Here is a change for better work with DST and timezones.

    /include/campsite_init.php

    // set timezone
    $timeZone = SystemPref::Get('TimeZone');
    if (!empty($timeZone)) {
        date_default_timezone_set($timeZone);
        $g_ado_db->Execute("SET SESSION time_zone = '" . date('P') . "'");
    } else {
        // Some people forget to set their timezone in their php.ini,
        // this prevents that from generating warnings
        @date_default_timezone_set(@date_default_timezone_get());
        //set timezone for mysql session
        $g_ado_db->Execute("SET SESSION time_zone = '" . date('P') . "'");

    }
    unset($timeZone);
    /admin-files/system_pref/index.php

            <?php
           
            $timeZoneCities = array(
                0 => 'London, Lisbon, Casablanca',
                1 => 'Brussels, Copenhagen, Madrid, Paris',
                2 => 'Athens, Istanbul, Jerusalem',
                3 => 'Baghdad, Riyadh, Moscow, St. Petersburg',
                4 => 'Abu Dhabi, Muscat, Baku, Tbilisi',
                5 => 'Ekaterinburg, Islamabad, Karachi, Tashkent',
                6 => 'Almaty, Dhaka, Colombo',
                7 => 'Bangkok, Hanoi, Jakarta',
                8 => 'Beijing, Perth, Singapore, Hong Kong',
                9 => 'Tokyo, Seoul, Osaka, Sapporo, Yakutsk',
                10 => 'Eastern Australia, Guam, Vladivostok',
                11 => 'Magadan, Solomon Islands, New Caledonia',
                12 => 'Auckland, Wellington, Fiji, Kamchatka',
                -1 => 'Azores, Cape Verde Islands',
                -2 => 'Mid-Atlantic',
                -3 => 'Brazil, Buenos Aires, Georgetown',
                -4 => 'Atlantic Time (Canada), Caracas, La Paz',
                -5 => 'Eastern Time (US & Canada), Bogota, Lima',
                -6 => 'Central Time (US & Canada), Mexico City',
                -7 => 'Mountain Time (US & Canada)',
                -8 => 'Pacific Time (US & Canada)',
                -9 => 'Alaska',
                -10 => 'Hawaii',
                -11 => 'Midway Island, Samoa',
                -12 => 'Eniwetok, Kwajalein',
            );
           
            $timeZone = SystemPref::Get('TimeZone');
            camp_html_select_option('', $timeZone, getGS('disabled'));
            for ($k = -12; $k < 13; $k++) {
                $v = $k < 0 ? $k : '+' . $k;
                if ($timeZoneCities[$k] != '') camp_html_select_option('Etc/GMT'.$v, $timeZone, "GMT $v:00 ({$timeZoneCities[$k]})");
                else camp_html_select_option($v, $timeZone, "GMT $v:00");
            }

            foreach(timezone_identifiers_list() as $tz) {
                camp_html_select_option($tz, $timeZone, $tz);
            }
            ?>




    Settting the timezone in php.ini is usable too (works with DST), but original code not set the timezone for mysql session. This issue is solved too.
    Post edited by Zsolt Baji at 2013-05-04 06:32:25