You’ll need SSH access to your EC2 instance before we do anything, so if you don’t have it already (or you don’t know what it is), here’s a handy guide.
SSH into your instance, then use the date
command to see what timezone is currently configured:
$ date
Sun Dec 23 21:36:49 UTC 2018
The second-to-last part is what we’re after, the timezone abbreviation. In this example, our instance is set to UTC, or Coordinated Universal Time, which is essentially Greenwich Mean Time without daylight savings.
We need to select the appropriate timezone. Let’s say our business is in New York City (Eastern Standard Time or EST), so using this handy chart, we can determine that the name of the nearest timezone is (conveniently) America/New_York
.
Next, we symlink to the appropriate timezone identifier:
sudo ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
And then we update the clock file, so this change will be retained on reboot. Open the file for editing:
sudo vi /etc/sysconfig/clock
Then change the current timezone (in red below) to the one you want and save:
ZONE="UTC" # becomes ZONE="America/New_York"
UTC=true
Note: Leave the second line (UTC=true
) alone. As Amazon notes in their documentation, this entry is for the hardware clock and doesn’t need to be changed when setting a different timezone.
Finally, reboot your instance to apply the changes:
sudo reboot
[You can also reboot an instance from the console, by navigating to EC2 > Instances
, clicking the blue box to the left of your instance, then selecting Instance State > Reboot
from the Actions
dropdown.]
Once the reboot is complete, SSH back in and rerun the date
command to confirm:
$ date
Sun Dec 23 16:36:49 EST 2018