Magento Expert Forum - Improve your Magento experience

Results 1 to 8 of 8

How to change default date and timezones for CentOS server?

  1. #1
    Moderator shunavi's Avatar
    Join Date
    Mar 2013
    Posts
    124
    Thanks
    9
    Thanked 26 Times in 17 Posts

    Thumbs up How to change default date and timezones for CentOS server?

    When I manage server, there are many times the server have no right timezone as I want or customers want to change timezone of their server. There are a few different ways to change the default date and timezone within CentOS operating system for web servers with only command line / SSH access.

    Here I only show you a simplest way to change timezone by tzselect

    First you may need to remove the existing symlink before using tzselect

    Code:
    rm -f /etc/localtime
    Then use tzselect to choose your timezone step by steps

    Code:
    tzselect
    Please identify a location so that time zone rules can be set correctly.
    Please select a continent or ocean.
     1) Africa
     2) Americas
     3) Antarctica
     4) Arctic Ocean
     5) Asia
     6) Atlantic Ocean
     7) Australia
     8) Europe
     9) Indian Ocean
    10) Pacific Ocean
    11) none - I want to specify the time zone using the Posix TZ format.
    #? 2
    Please select a country.
     1) Anguilla                       28) Haiti
     2) Antigua & Barbuda              29) Honduras
     3) Argentina                      30) Jamaica
     4) Aruba                          31) Martinique
     5) Bahamas                        32) Mexico
     6) Barbados                       33) Montserrat
     7) Belize                         34) Nicaragua
     8) Bolivia                        35) Panama
     9) Bonaire Sint Eustatius & Saba  36) Paraguay
    10) Brazil                         37) Peru
    11) Canada                         38) Puerto Rico
    12) Cayman Islands                 39) Sint Maarten
    13) Chile                          40) St Barthelemy
    14) Colombia                       41) St Kitts & Nevis
    15) Costa Rica                     42) St Lucia
    16) Cuba                           43) St Martin (French part)
    17) Curacao                        44) St Pierre & Miquelon
    18) Dominica                       45) St Vincent
    19) Dominican Republic             46) Suriname
    20) Ecuador                        47) Trinidad & Tobago
    21) El Salvador                    48) Turks & Caicos Is
    22) French Guiana                  49) United States
    23) Greenland                      50) Uruguay
    24) Grenada                        51) Venezuela
    25) Guadeloupe                     52) Virgin Islands (UK)
    26) Guatemala                      53) Virgin Islands (US)
    27) Guyana
    #? 5
    
    The following information has been given:
    
            Bahamas
    
    Therefore TZ='America/Nassau' will be used.
    Local time is now:      Sat Feb 25 10:28:19 EST 2012.
    Universal Time is now:  Sat Feb 25 15:28:19 UTC 2012.
    Is the above information OK?
    1) Yes
    2) No
    #? y
    Please enter 1 for Yes, or 2 for No.
    #? 1
    
    You can make this change permanent for yourself by appending the line
            TZ='America/Nassau'; export TZ
    to the file '.profile' in your home directory; then log out and log in again.
    
    Here is that TZ value again, this time on standard output so that you
    can use the /usr/bin/tzselect command in shell scripts:
    America/Nassau
    Now let 's restart your server to make sure everything work well.

    As a bonus, here I will show you what timezone are supported on your server.

    This command will list all countries

    Code:
    ls /usr/share/zoneinfo/
    Let 's say you are in Australia then use this to list all supported timezone area in Australia

    Code:
    ls /usr/share/zoneinfo/Australia/
    In manual way you can make a shellscript like this:

    Code:
    ZONEINFO=Australia/Brisbane
    rm -f /etc/localtime
    ln -s /usr/share/zoneinfo/$ZONEINFO /etc/localtime
    and just run it to change to your timezone.

    Happy coding

    View more threads in the same category:


  2. #2
    Junior Member bond's Avatar
    Join Date
    Jun 2013
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Oh, it take me a day to research. Thanks shunavi, you save me a lot of time.

  3. #3
    Administrator david's Avatar
    Join Date
    Nov 2012
    Posts
    261
    Thanks
    22
    Thanked 42 Times in 34 Posts

    Default

    In Ubuntu you guys can use this simple command

    Code:
    sudo dpkg-reconfigure tzdata

  4. #4
    Junior Member jacobwallace's Avatar
    Join Date
    Nov 2014
    Location
    Hyderabad
    Posts
    15
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by shunavi View Post
    When I manage server, there are many times the server have no right timezone as I want or customers want to change timezone of their server. There are a few different ways to change the default date and timezone within CentOS operating system for web servers with only command line / SSH access.

    Here I only show you a simplest way to change timezone by tzselect

    First you may need to remove the existing symlink before using tzselect

    Code:
    rm -f /etc/localtime
    Then use tzselect to choose your timezone step by steps

    Code:
    tzselect
    Please identify a location so that time zone rules can be set correctly.
    Please select a continent or ocean.
     1) Africa
     2) Americas
     3) Antarctica
     4) Arctic Ocean
     5) Asia
     6) Atlantic Ocean
     7) Australia
     8) Europe
     9) Indian Ocean
    10) Pacific Ocean
    11) none - I want to specify the time zone using the Posix TZ format.
    #? 2
    Please select a country.
     1) Anguilla                       28) Haiti
     2) Antigua & Barbuda              29) Honduras
     3) Argentina                      30) Jamaica
     4) Aruba                          31) Martinique
     5) Bahamas                        32) Mexico
     6) Barbados                       33) Montserrat
     7) Belize                         34) Nicaragua
     8) Bolivia                        35) Panama
     9) Bonaire Sint Eustatius & Saba  36) Paraguay
    10) Brazil                         37) Peru
    11) Canada                         38) Puerto Rico
    12) Cayman Islands                 39) Sint Maarten
    13) Chile                          40) St Barthelemy
    14) Colombia                       41) St Kitts & Nevis
    15) Costa Rica                     42) St Lucia
    16) Cuba                           43) St Martin (French part)
    17) Curacao                        44) St Pierre & Miquelon
    18) Dominica                       45) St Vincent
    19) Dominican Republic             46) Suriname
    20) Ecuador                        47) Trinidad & Tobago
    21) El Salvador                    48) Turks & Caicos Is
    22) French Guiana                  49) United States
    23) Greenland                      50) Uruguay
    24) Grenada                        51) Venezuela
    25) Guadeloupe                     52) Virgin Islands (UK)
    26) Guatemala                      53) Virgin Islands (US)
    27) Guyana
    #? 5
    
    The following information has been given:
    
            Bahamas
    
    Therefore TZ='America/Nassau' will be used.
    Local time is now:      Sat Feb 25 10:28:19 EST 2012.
    Universal Time is now:  Sat Feb 25 15:28:19 UTC 2012.
    Is the above information OK?
    1) Yes
    2) No
    #? y
    Please enter 1 for Yes, or 2 for No.
    #? 1
    
    You can make this change permanent for yourself by appending the line
            TZ='America/Nassau'; export TZ
    to the file '.profile' in your home directory; then log out and log in again.
    
    Here is that TZ value again, this time on standard output so that you
    can use the /usr/bin/tzselect command in shell scripts:
    America/Nassau
    Now let 's restart your server to make sure everything work well.

    As a bonus, here I will show you what timezone are supported on your server.

    This command will list all countries

    Code:
    ls /usr/share/zoneinfo/
    Let 's say you are in Australia then use this to list all supported timezone area in Australia

    Code:
    ls /usr/share/zoneinfo/Australia/
    In manual way you can make a shellscript like this:

    Code:
    ZONEINFO=Australia/Brisbane
    rm -f /etc/localtime
    ln -s /usr/share/zoneinfo/$ZONEINFO /etc/localtime
    and just run it to change to your timezone.

    Happy coding

    Thanks shunavi this is a very utilized information for me . keep it on.

  5. #5
    Junior Member
    Join Date
    Sep 2018
    Location
    United Kingdom
    Posts
    228
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default

    So the most ideal approach to change time zone of server is to interface/and so forth/localtime document to address design record under/usr/share/zoneinfo/records. First check current timezone utilized by your framework utilizing date direction. According to above model our framework timezone is set to EST.

  6. #6
    Junior Member
    Join Date
    Sep 2018
    Location
    Oman, Muscat
    Posts
    2,084
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default

    Set timezone Centos

    Changing the time and timezone settings on CentOS or RHEL
    Change your timezone. # mv/and so on/localtime/and so forth/localtime.backup # ln - s/usr/share/zoneinfo/Europe/Brussels/and so forth/localtime.
    Change your present time on the server. On the off chance that your clock is off on the server, first check if the timezone (clarified above) is right.
    Discretionary: duplicate the timezone documents from another server.

Similar Threads

  1. Install Redis Server and PHP Redis on Ubuntu Server
    By shunavi in forum Magento Dedicated server
    Replies: 3
    Last Post: 04-06-2020, 06:57 AM
  2. Resetting MySQL Root Password: Red Hat and CentOS
    By david in forum Programming & Development
    Replies: 0
    Last Post: 03-04-2013, 08:12 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •