Tag: timezone

  • Changing or Updating the time zone in Ubuntu Server

     

    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:

     

    date

     

    to verify that it worked!

  • Ubuntu: How to update PHP’s timezone

     

    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:

     

    /etc/php5/apache2/php.ini

     

    Look for the Module Settings section or search for:

     

     date.timezone

     

    (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:

     

    [Date]

    ; Defines the default timezone used by the date functions

    ; http://php.net/date.timezone

    date.timezone = UTC+10

     

    Change UTC+10 to your desired timezone, save the file and restart Apache:

     

    sudo service apache2 restart

     

    Voila!