Magento Expert Forum - Improve your Magento experience

Results 1 to 4 of 4

How to change default date and timezones for CentOS server?

  1. #1
    Moderator shunavi's Avatar
    Join Date
    Mar 2013
    Posts
    130
    Thanks
    10
    Thanked 29 Times in 15 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
    260
    Thanks
    23
    Thanked 40 Times in 33 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
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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.

Similar Threads

  1. Install Redis Server and PHP Redis on Ubuntu Server
    By shunavi in forum Magento Dedicated server
    Replies: 1
    Last Post: 04-04-2015, 08:03 AM
  2. Resetting MySQL Root Password: Red Hat and CentOS
    By david in forum Programming & Development
    Replies: 0
    Last Post: 03-04-2013, 09: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
  •