Search This Blog

Wednesday, August 21, 2013

BeagleBone Black: setting the correct timezone

Set your localtime file according to your time zone

Next you need to set your /etc/localtime file according to your timezone.
If you go into the directory /usr/share/zoneinfo you will see a lot of different timezone files, e.g. 

root@beaglebone:/usr/share/zoneinfo# ls
Africa CET EST5EDT GMT Greenwich MST7MDT PST8PDT UCT WET America CST6CDT Etc GMT+0 HST NZ Pacific UTC Zulu Asia EET Europe GMT-0 MET NZ-CHAT ROC Universal iso3166.tab Australia EST GB GMT0 MST PRC ROK W-SU zone.tab

You can copy the file directly or use one of the presets. In my case, Irish time is the same as London time. So,

root@beaglebone:/usr/share/zoneinfo# cd Europe/
root@beaglebone:/usr/share/zoneinfo/Europe# ls -al

total 20 
drwxr-xr-x 2 root root 4096 Mar 18 2013 . 
drwxr-xr-x 9 root root 4096 Jan 1 11:42 .. 
-rw-r--r-- 1 root root 3661 Mar 19 2013 London
-rw-r--r-- 1 root root 1464 Mar 19 2013 Moscow
-rw-r--r-- 1 root root 2945 Mar 19 2013 Paris

So, I am going to use the London file – back to the /etc directory:

root@beaglebone:/etc# rm localtime
root@beaglebone:/etc# ln -s /usr/share/zoneinfo/Europe/London /etc/localtime

by setting a symbolic link from /etc/localtime to the timezone file. The advantage of this over copying the file is that you can see the timezone that was set when you ls:

root@beaglebone:/etc# ls -al|grep localtime 
lrwxrwxrwx 1 root root 33 Jan 1 12:05 localtime -> /usr/share/zoneinfo/Europe/London

root@beaglebone:/etc# ls -al localtime 
lrwxrwxrwx 1 root root 33 Jan 1 12:05 localtime -> /usr/share/zoneinfo/Europe/London

source