Setting Timezone using timedatectl


I am using Colibri-imx6 with Linux OS. I am trying to set timezone to Detroit using timedatectl.

The command I use timedatectl set-timezone America/Detroit . I am not able to set the timezone. I get the following error

Failed to set time zone: Invalid time zone ‘America/Detroit’

I am able to set the timezone by creating a symlink. However the zoneinfo has very limited timezones.

Is there any other way to set timezone through user program ? I tried setting the tz environment variable but it resets the time to system time once the program execution is over.



We do not install the timezone databases in our demo images. Unfortunately the list of potentially available timezones is known to timezone utilities, so you may get the impression that you can use America/Detroit while in fact the required data file is not available.

You could add tzdata-americas (or tzdata for all data) to your image and rebuild the image if you are using a Yocto setup.
Alternatively you could install it with:

opkg update
opkg install tzdata-americas


Hey Max,

How can I set timezone with an user program ? I tried using tzset() but the timezone gets reset after program completion.



I don’t really know.

I guess tzset() does only influence the current process and likely spawned child processes.

Assuming that changing the system timezone is a rare thing to do, why not using system() to call the timedatectl command line tool?

Or one could use the dbus interface to access systemd’s timedated deamon.


Hi Max,

How we can preinstall timezone package into the Yocto Image build, chain instead of update install later?

For example this package:



Add the package to the IMAGE_INSTALL variable, e.g. have a look here.
Note that the package name is the first part of the ipk file name up to the first ‘_’. E.g. in your example this would be tzdata-europe.