Discover Centmin Mod today
Register Now

Featured Install Changing default CentOS system timezones

Discussion in 'Install & Upgrades or Pre-Install Questions' started by eva2000, Jun 8, 2014.

  1. eva2000

    eva2000 Administrator Staff Member

    33,749
    7,468
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,481
    Local Time:
    11:39 PM
    Nginx 1.13.x
    MariaDB 5.5
    In centmin.sh there's a variable called ZONEINFO which can be changed prior to Centmin Mod install to set the default CentOS system timezone. This system timezone can also be changed after install as per FAQ 8 http://centminmod.com/faq.html.

    Full example of post-install timezone changes are outlined at http://centminmod.com/datetimezones.html.

    For example for Greece, Athens you can use ZONEINFO=Europe/Athens

    Code:
    ls -lah /usr/share/zoneinfo/Europe/
    total 244K
    drwxr-xr-x.  2 root root 4.0K Jun  2 06:33 .
    drwxr-xr-x. 20 root root 4.0K Jun  2 06:33 ..
    -rw-r--r--.  1 root root 2.9K May 15 05:05 Amsterdam
    -rw-r--r--.  1 root root 1.7K May 15 05:05 Andorra
    -rw-r--r--.  1 root root 2.2K May 15 05:05 Athens
    -rw-r--r--.  7 root root 3.6K May 15 05:05 Belfast
    -rw-r--r--.  6 root root 1.9K May 15 05:05 Belgrade
    -rw-r--r--.  1 root root 2.3K May 15 05:05 Berlin
    -rw-r--r--.  2 root root 2.2K May 15 05:05 Bratislava
    -rw-r--r--.  1 root root 2.9K May 15 05:05 Brussels
    -rw-r--r--.  1 root root 2.2K May 15 05:05 Bucharest
    -rw-r--r--.  1 root root 2.4K May 15 05:05 Budapest
    -rw-r--r--.  3 root root 1.9K May 15 05:05 Busingen
    -rw-r--r--.  2 root root 2.4K May 15 05:05 Chisinau
    -rw-r--r--.  1 root root 2.1K May 15 05:05 Copenhagen
    -rw-r--r--.  2 root root 3.5K May 15 05:05 Dublin
    -rw-r--r--.  1 root root 3.0K May 15 05:05 Gibraltar
    -rw-r--r--.  7 root root 3.6K May 15 05:05 Guernsey
    -rw-r--r--.  2 root root 1.9K May 15 05:05 Helsinki
    -rw-r--r--.  7 root root 3.6K May 15 05:05 Isle_of_Man
    -rw-r--r--.  3 root root 2.7K May 15 05:05 Istanbul
    -rw-r--r--.  7 root root 3.6K May 15 05:05 Jersey
    -rw-r--r--.  1 root root 1.5K May 15 05:05 Kaliningrad
    -rw-r--r--.  1 root root 2.1K May 15 05:05 Kiev
    -rw-r--r--.  2 root root 3.4K May 15 05:05 Lisbon
    -rw-r--r--.  6 root root 1.9K May 15 05:05 Ljubljana
    -rw-r--r--.  7 root root 3.6K May 15 05:05 London
    -rw-r--r--.  1 root root 2.9K May 15 05:05 Luxembourg
    -rw-r--r--.  1 root root 2.6K May 15 05:05 Madrid
    -rw-r--r--.  1 root root 2.6K May 15 05:05 Malta
    -rw-r--r--.  2 root root 1.9K May 15 05:05 Mariehamn
    -rw-r--r--.  1 root root 1.3K May 15 05:05 Minsk
    -rw-r--r--.  1 root root 2.9K May 15 05:05 Monaco
    -rw-r--r--.  2 root root 1.5K May 15 05:05 Moscow
    -rw-r--r--.  2 root root 2.0K May 15 05:05 Nicosia
    -rw-r--r--.  3 root root 2.2K May 15 05:05 Oslo
    -rw-r--r--.  1 root root 2.9K May 15 05:05 Paris
    -rw-r--r--.  6 root root 1.9K May 15 05:05 Podgorica
    -rw-r--r--.  2 root root 2.2K May 15 05:05 Prague
    -rw-r--r--.  1 root root 2.2K May 15 05:05 Riga
    -rw-r--r--.  3 root root 2.6K May 15 05:05 Rome
    -rw-r--r--.  1 root root 1.3K May 15 05:05 Samara
    -rw-r--r--.  3 root root 2.6K May 15 05:05 San_Marino
    -rw-r--r--.  6 root root 1.9K May 15 05:05 Sarajevo
    -rw-r--r--.  1 root root 1.5K May 15 05:05 Simferopol
    -rw-r--r--.  6 root root 1.9K May 15 05:05 Skopje
    -rw-r--r--.  1 root root 2.1K May 15 05:05 Sofia
    -rw-r--r--.  1 root root 1.9K May 15 05:05 Stockholm
    -rw-r--r--.  1 root root 2.2K May 15 05:05 Tallinn
    -rw-r--r--.  1 root root 2.1K May 15 05:05 Tirane
    -rw-r--r--.  2 root root 2.4K May 15 05:05 Tiraspol
    -rw-r--r--.  1 root root 2.1K May 15 05:05 Uzhgorod
    -rw-r--r--.  3 root root 1.9K May 15 05:05 Vaduz
    -rw-r--r--.  3 root root 2.6K May 15 05:05 Vatican
    -rw-r--r--.  1 root root 2.2K May 15 05:05 Vienna
    -rw-r--r--.  1 root root 2.2K May 15 05:05 Vilnius
    -rw-r--r--.  1 root root 1.2K May 15 05:05 Volgograd
    -rw-r--r--.  2 root root 2.7K May 15 05:05 Warsaw
    -rw-r--r--.  6 root root 1.9K May 15 05:05 Zagreb
    -rw-r--r--.  1 root root 2.1K May 15 05:05 Zaporozhye
    -rw-r--r--.  3 root root 1.9K May 15 05:05 Zurich
    You'd want to change your /usr/local/lib/php.ini defined timezone too date.timezone according to predefined ones at http://www.php.net//manual/en/timezones.php
     
    Last edited: Jun 9, 2014
    • Like Like x 1
  2. RoldanLT

    RoldanLT Well-Known Member

    4,157
    1,007
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,421
    Local Time:
    9:39 PM
    1.11
    10.2
    It didn't apply automatically for me with Asia/Manila on php.ini on my 1st install.
     
  3. eva2000

    eva2000 Administrator Staff Member

    33,749
    7,468
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,481
    Local Time:
    11:39 PM
    Nginx 1.13.x
    MariaDB 5.5
    it should set to UTC with inc/phpsededit.inc line 2 to 6 at https://github.com/centminmod/centminmod/blob/123.07beta21/inc/phpsededit.inc#L2

    Code:
        if [[ "$(date +"%Z")" = 'EST' ]]; then
        sed -i "s/;date.timezone =/date.timezone = Australia\/Brisbane/g" /usr/local/lib/php.ini
        else
        sed -i "s/;date.timezone =/date.timezone = UTC/g" /usr/local/lib/php.ini
        fi
    what does the command below return
    Code:
    echo $(date +"%Z")
     
  4. RoldanLT

    RoldanLT Well-Known Member

    4,157
    1,007
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,421
    Local Time:
    9:39 PM
    1.11
    10.2
    It's "PHT" because I manually edited the php.ini file.
     
  5. RoldanLT

    RoldanLT Well-Known Member

    4,157
    1,007
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,421
    Local Time:
    9:39 PM
    1.11
    10.2
    For Philippines I should use UTC or EST?
     
  6. eva2000

    eva2000 Administrator Staff Member

    33,749
    7,468
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,481
    Local Time:
    11:39 PM
    Nginx 1.13.x
    MariaDB 5.5
    For system timezone or PHP ?

    For system pick closest city on Asia directory listing, i.e. Asia/Manila

    Code:
    ls /usr/share/zoneinfo/Asia/   
    Aden      Ashkhabad  Brunei      Damascus  Hebron       Jayapura   Katmandu      Macao     Novokuznetsk  Qatar      Seoul      Tel_Aviv       Urumqi
    Almaty    Baghdad    Calcutta    Dhaka     Ho_Chi_Minh  Jerusalem  Khandyga      Macau     Novosibirsk   Qyzylorda  Shanghai   Thimbu         Ust-Nera
    Amman     Bahrain    Choibalsan  Dili      Hong_Kong    Kabul      Kolkata       Magadan   Omsk          Rangoon    Singapore  Thimphu        Vientiane
    Anadyr    Baku       Chongqing   Dubai     Hovd         Kamchatka  Krasnoyarsk   Makassar  Oral          Riyadh     Taipei     Tokyo          Vladivostok
    Aqtau     Bangkok    Chungking   Dushanbe  Irkutsk      Karachi    Kuala_Lumpur  Manila    Phnom_Penh    Saigon     Tashkent   Ujung_Pandang  Yakutsk
    Aqtobe    Beirut     Colombo     Gaza      Istanbul     Kashgar    Kuching       Muscat    Pontianak     Sakhalin   Tbilisi    Ulaanbaatar    Yekaterinburg
    Ashgabat  Bishkek    Dacca       Harbin    Jakarta      Kathmandu  Kuwait        Nicosia   Pyongyang     Samarkand  Tehran     Ulan_Bator     Yerevan
    For PHP closest on Asia listing http://www.php.net/manual/en/timezones.php at http://www.php.net/manual/en/timezones.asia.php

    Code:
    Asia/Aden    Asia/Almaty    Asia/Amman    Asia/Anadyr    Asia/Aqtau
    Asia/Aqtobe    Asia/Ashgabat    Asia/Ashkhabad    Asia/Baghdad    Asia/Bahrain
    Asia/Baku    Asia/Bangkok    Asia/Beirut    Asia/Bishkek    Asia/Brunei
    Asia/Calcutta    Asia/Choibalsan    Asia/Chongqing    Asia/Chungking    Asia/Colombo
    Asia/Dacca    Asia/Damascus    Asia/Dhaka    Asia/Dili    Asia/Dubai
    Asia/Dushanbe    Asia/Gaza    Asia/Harbin    Asia/Hebron    Asia/Ho_Chi_Minh
    Asia/Hong_Kong    Asia/Hovd    Asia/Irkutsk    Asia/Istanbul    Asia/Jakarta
    Asia/Jayapura    Asia/Jerusalem    Asia/Kabul    Asia/Kamchatka    Asia/Karachi
    Asia/Kashgar    Asia/Kathmandu    Asia/Katmandu    Asia/Khandyga    Asia/Kolkata
    Asia/Krasnoyarsk    Asia/Kuala_Lumpur    Asia/Kuching    Asia/Kuwait    Asia/Macao
    Asia/Macau    Asia/Magadan    Asia/Makassar    Asia/Manila    Asia/Muscat
    Asia/Nicosia    Asia/Novokuznetsk    Asia/Novosibirsk    Asia/Omsk    Asia/Oral
    Asia/Phnom_Penh    Asia/Pontianak    Asia/Pyongyang    Asia/Qatar    Asia/Qyzylorda
    Asia/Rangoon    Asia/Riyadh    Asia/Saigon    Asia/Sakhalin    Asia/Samarkand
    Asia/Seoul    Asia/Shanghai    Asia/Singapore    Asia/Taipei    Asia/Tashkent
    Asia/Tbilisi    Asia/Tehran    Asia/Tel_Aviv    Asia/Thimbu    Asia/Thimphu
    Asia/Tokyo    Asia/Ujung_Pandang    Asia/Ulaanbaatar    Asia/Ulan_Bator    Asia/Urumqi
    Asia/Ust-Nera    Asia/Vientiane    Asia/Vladivostok    Asia/Yakutsk    Asia/Yekaterinburg
     
  7. rc112

    rc112 Member

    124
    14
    18
    Sep 22, 2017
    Ratings:
    +15
    Local Time:
    9:39 PM
    Hi @eva2000 I had timezone set up as below in custom config file but I ran date and it output UTC, still.
    Code:
    [20:16][root@centmin ~]# cat /etc/centminmod/custom_config.inc
    ZONEINFO=Asia/Taipei  # Set Timezone
    ZOPCACHEDFT='y'
    PHP_VERSION='7.1.15'
    NGINX_IPV='y'
    PHP_PGO='y'  # Use PHP 7.x with Profile Guide Optimizations (PGO)
    NGXDYNAMIC_BROTLI='y'
    NGINX_LIBBROTLI='y'
    CLOUDFLARE_ZLIBPHP='y' # use Cloudflare optimised zlib fork for PHP-FPM zlib instead of system zlib
    CLOUDFLARE_PATCHSSL='y'   # set 'y' to implement Cloudflare's chacha20 patch  [https://github.com/cloudflare/sslconfig](https://github.com/cloudflare/sslconfig)
    NGINX_DYNAMICTLS='y'    # set 'y' and recompile nginx  [https://blog.cloudflare.com/optimizing-tls-over-tcp-to-reduce-latency/](https://blog.cloudflare.com/optimizing-tls-over-tcp-to-reduce-latency/)
    OPENSSLECDSA_PATCH='y' # https://community.centminmod.com/posts/57725/
    OPENSSLECDHX_PATCH='y' # https://community.centminmod.com/posts/57726/
    Should I still set up a seperate custom file for php timezone? Thanks.
     
  8. Revenge

    Revenge Active Member

    383
    80
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +287
    Local Time:
    2:39 PM
    1.9.x
    10.1.x
    Run this command:

    mv /etc/localtime /etc/localtime.bak
    ln -s /usr/share/zoneinfo/Asia/Taipei /etc/localtime

    Reboot the server after that.
     
  9. rc112

    rc112 Member

    124
    14
    18
    Sep 22, 2017
    Ratings:
    +15
    Local Time:
    9:39 PM
    Hi @eva2000

    1. Is it a bug? Or something I did wrong?
    2. I follow your other command on the forum to change and ran date and output the correct timezone.
    3. I also did this.
      Code:
      vi /etc/centminmod/php.d/custom.ini
      date.timezone = Asia/Taipei
      fpmrestart
      How can I know php has the correct time zone? Thank you so mucn.
     
  10. eva2000

    eva2000 Administrator Staff Member

    33,749
    7,468
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,481
    Local Time:
    11:39 PM
    Nginx 1.13.x
    MariaDB 5.5
    pay attention to instructions in 1st post Install - Changing default CentOS system timezones centos 7 method is different from centos 6 method as well

    to check php timezone check phpinfo page or via command line phpinfo with grep filter on timezone keyword
    Code (Text):
    php -i | grep timezone
    

    Code (Text):
    php -i | grep timezone
    Default timezone => UTC
    date.timezone => UTC => UTC
    


    fyi, I generally use UTC time cause if you have multiple servers it easier to see what's happing at UTC time

    Centmin Mod also sets a mytimes custom command which outputs various common timezones if the only reason you want to change timezone is to be able to see your timezone

    Code (Text):
     mytimes
    Fri Mar  2 20:27:16 UTC 2018    [UTC]
    Sat Mar  3 06:27:16 AEST 2018   [Australia/Brisbane]
    Fri Mar  2 12:27:16 PST 2018    [America/Los_Angeles]
    Fri Mar  2 14:27:16 CST 2018    [America/Chicago]
    Fri Mar  2 15:27:16 EST 2018    [America/New_York]
    Fri Mar  2 15:27:16 EST 2018    [America/Montreal]
    Fri Mar  2 20:27:16 GMT 2018    [Europe/London]
    Fri Mar  2 21:27:16 CET 2018    [Europe/Berlin]
    Sat Mar  3 03:27:16 +07 2018    [Asia/Bangkok]
    Sat Mar  3 03:27:16 +07 2018    [Asia/Ho_Chi_Minh]
    Sat Mar  3 03:27:16 WIB 2018    [Asia/Jakarta]
    Sat Mar  3 04:27:16 +08 2018    [Asia/Kuala_Lumpur]
    Sat Mar  3 04:27:16 +08 2018    [Asia/Singapore]
    
     
    Last edited: Mar 3, 2018
  11. rc112

    rc112 Member

    124
    14
    18
    Sep 22, 2017
    Ratings:
    +15
    Local Time:
    9:39 PM
    Yes, I used the method below to post-edit the timezone.
    Code:
    timedatectl set-timezone America/Los_Angeles
    But the reason why I asked is I got
    Code:
    ZONEINFO=Asia/Taipei  # Set Timezone
    in custom config file but it didnt take effect. I ran date and it still output UTC.
    Thank for your advice.
     
  12. eva2000

    eva2000 Administrator Staff Member

    33,749
    7,468
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,481
    Local Time:
    11:39 PM
    Nginx 1.13.x
    MariaDB 5.5
    You can grep filter your initial install log in /root/centminlogs to see what was set during initial install

    Code (Text):
    grep -A3 'preferred localtime' "$(echo "/root/centminlogs/$(ls /root/centminlogs/ | grep _install.log)")" 
    

    the basically finds install log name using
    Code (Text):
    ls /root/centminlogs/ | grep _install.log
    centminmod_123.09beta01.b016_250218-032050_install.log
    

    and does a grep -A3 for keywords 'preferred localtime' so returns matching keyword and the 3 lines after it

    so example output
    Code (Text):
    grep -A3 'preferred localtime' "$(echo "/root/centminlogs/$(ls /root/centminlogs/ | grep _install.log)")" 
    * Setting preferred localtime for VPS
    *************************************************
    Current date & time for the zone you selected is:
    Sun Feb 25 03:22:09 UTC 2018
    
     
  13. rc112

    rc112 Member

    124
    14
    18
    Sep 22, 2017
    Ratings:
    +15
    Local Time:
    9:39 PM
    Here is the output. It didnt set up correctly at the first place. Not sure if it is also related to the character.
    Code:
    [06:13][root@centmin ~]# grep -A3 'preferred localtime' "$(echo "/root/centminlogs/$(ls /root/centminlogs/ | grep _install.log)")"
    * Setting preferred localtime for VPS
    *************************************************
    Current date & time for the zone you selected is:
    Fri Mar  2 08:14:16 UTC 2018
     
  14. eva2000

    eva2000 Administrator Staff Member

    33,749
    7,468
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,481
    Local Time:
    11:39 PM
    Nginx 1.13.x
    MariaDB 5.5
    might be due to method used for centos 6 and not 7 so might need to update the routine

    will update 123.09beta01 in a few moments :)
     
    • Like Like x 2
  15. rc112

    rc112 Member

    124
    14
    18
    Sep 22, 2017
    Ratings:
    +15
    Local Time:
    9:39 PM
    I will try with a new server. :D Thank you so much as always. Have a great weekend.
     
  16. eva2000

    eva2000 Administrator Staff Member

    33,749
    7,468
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,481
    Local Time:
    11:39 PM
    Nginx 1.13.x
    MariaDB 5.5
    Just updated with fix :)
     
    • Like Like x 1
  17. rc112

    rc112 Member

    124
    14
    18
    Sep 22, 2017
    Ratings:
    +15
    Local Time:
    9:39 PM
    So I need to update centminmod by running option23 > option2 if I previously have set up git base with option 1? Thank you.
     
  18. eva2000

    eva2000 Administrator Staff Member

    33,749
    7,468
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,481
    Local Time:
    11:39 PM
    Nginx 1.13.x
    MariaDB 5.5
    this can only be tested on fresh centmin mod 123.09beta01 installs

    initial install time is only time the timezone is updated
     
  19. rc112

    rc112 Member

    124
    14
    18
    Sep 22, 2017
    Ratings:
    +15
    Local Time:
    9:39 PM
    yes, got it. Thank you for your hard work. thumb up!
     
    • Like Like x 1
..