There are quite a few reasons you may find that you need to change your time zone – for example, if you’re using a pre-made image for a virtual machine you may find that the default timezone is not set to your country. You can change the time manually, though there is a quick and easy way:
sudo dpkg-reconfigure tzdata
This reconfigures the tzdata (timezone data) package and runs you through a series of prompts asking which country/city you live in, and updates the time accordingly.
You can check the current system time with:
to verify that it worked!
We came across this one recently when setting up a Zabbix server, where the installation would not proceed until the PHP timezone was set. This is quite straightforward – using your favourite editor edit:
Look for the Module Settings section or search for:
(in vi /date.timezone should get you there). Uncomment the line by removing the leading ; and then add in your desired timezone. For Sydney it would look like:
; Defines the default timezone used by the date functions
date.timezone = UTC+10
Change UTC+10 to your desired timezone, save the file and restart Apache:
sudo service apache2 restart