Ultimate Web Tips
your Wordpress, jQuery, PHP, MySQL, Linux and CSS guide to a successful website
Read more:

December 2nd, 2011

Update time and timezone in Linux from command prompt

Linux, by Joakim Ling.

Update timezone and time in LinuxThe system time is often a symlink to the file /etc/localtime or the time zone file on the time zone directory. The definition for time zones can be written in short form as UTC±n (or GMT±n), where n is the offset in hours.

Set time

To view current date and time type “date” in your terminal or ssh session. Use “date” to update date and time, remember you need to be root to do this.

# date
Mon Dec  5 08:07:30 EST 2011

To set a new date and time: date –set=”STRING”

# date --set="6 DEC 2011 08:10:00"
Tue Dec  6 08:10:00 EST 2011

Change timezone

To change timezone we need to create a symlink to /etc/localtime from the new timezone in /usr/share/zoneinfo/

To set to CET:

# cd /etc/
# rm -f localtime
# ln -sf /usr/share/zoneinfo/Europe/Stockholm localtime
# date
Mon Dec  5 14:15:02 CET 2011

Change timezone in PHP

date_default_timezone_set('Europe/Stockholm');

Linux training

If you need to improve your skills try my linux training guide, read more

Back Top

Club World Casinos
  • Tony$s

    you can also export like this
    $ export TZ=CET