• Elastic Cloud Server

ecs
  1. Help Center
  2. Elastic Cloud Server
  3. User Guide
  4. Configuration Modifications
  5. Changing the Time Zone for an ECS

Changing the Time Zone for an ECS

Scenarios

The default time zone for an ECS is the one you selected when creating the image that was used to create the ECS. This section describes how to change the time zone for an ECS to the local one or to another time zone in your network.

After you log in to your ECS, if you find that the time on the ECS is different from the local time, change the time zone for the ECS so that the time on the ECS is the same as the local time.

For Linux

The process of changing the time zone for a Linux ECS depends on the OS. In this section, the CentOS 6.x 64bit OS is used to demonstrate how to change the time zone for a Linux ECS.

  1. Log in to the ECS.
  2. Run the following command to switch to user root:

    su - root

  3. Run the following command to obtain the time zones supported by the ECS:

    ls /usr/share/zoneinfo/

    In the terminal display, the /user/share/zoneinfo directory contains a hierarchy of time zone data files. Use the directory structure shown in Figure 1 to obtain your desired time zone file.

    Figure 1 Time zones supported by the ECS

    The directory structure shown in Figure 1 includes both time zones and directories. The directories contain time zone files for specific cities. Locate the time zone for the city in which the ECS is located.

    For example:

    • If you are to use the time zone for Hong Kong, the directory in which the time zone file is stored is /usr/share/zoneinfo/Hongkong.
    • If you are to use the time zone for Paris, France, run the ls /usr/share/zoneinfo/Europe command to obtain the directory /usr/share/zoneinfo/Europe/Paris.
  4. Set the target time zone.
    1. Run the following command to open the /etc/sysconfig/clock file:

      vim /etc/sysconfig/clock

    2. Locate the ZONE entry and change its value to the name of the desired time zone file.

      For example:

      • If the target time zone is for Hong Kong, change the ZONE entry value to Hongkong:

        ZONE="Hongkong"

      • If the target time zone is for Paris, change the ZONE entry value to Paris:

        ZONE="Europe/Paris"

  5. Press Esc. Then, run the following command to save and exit the /etc/sysconfig/clock file:

    :wq

  6. Run the following command to check whether the /etc/localtime file is available on the ECS:

    ls /etc/localtime

    • If the file is available, go to step 7.
    • If the file is not available, go to step 8.
  7. Run the following command to delete the existing /etc/localtime file:

    rm /etc/localtime

  8. Run the following command to create a symbolic link between /etc/localtime and your time zone file so that the ECS can find this time zone file when it references the local time:

    ln -sf /usr/share/zoneinfo/Hongkong /etc/localtime

  9. Run the following command to restart the ECS so that all services and applications running on the ECS use the new time zone:

    reboot

  10. Log in to the ECS again and run the following command as user root to check whether the time zone has been changed:

    ls -lh /etc/localtime

For Windows

  1. Log in to the ECS.
  2. Click the time display on the far right side of the task bar located at the bottom of your screen. In the dialog box that is displayed, click Change date and time settings.

    The Date and Time is displayed.

    Figure 2 Date and Time
  3. Click Change time zone.

    The Time Zone Settings page is displayed.

  4. In the Set the time zone pane, choose the target time zone from the Time zone drop-down list.
  5. Click OK.