# Timezone Troubles

**URL:** <https://forums.balena.io/t/timezone-troubles/122430>\
**Category:** balenaOS\
**Tags:** raspberrypi3, time\
**Created:** [May 30, 2020, 12:55pm UTC](https://forums.balena.io/t/timezone-troubles/122430 "2020-05-30T12:55:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![henryh](https://avatars.discourse-cdn.com/v4/letter/h/dfb087/32.png) [@henryh](https://forums.balena.io/u/henryh)\
**Post date:** [May 30, 2020, 12:55pm UTC](https://forums.balena.io/t/timezone-troubles/122430/1 "2020-05-30T12:55:42Z")

</div>

I’ve been trying to setup timezones but it does not seem to work.  
Following [this](https://github.com/balena-io-examples/balena-timezone), I tried creating an environment variable “TIMEZONE” with value “Europe/Berlin”. That did not seem to have any effect. It feels like a really obvious thing to be able to do, but it seems that I’m missing something. I’d appreciate any pointers.

Using:

- balenaOS 2.47.0+rev1
- RPi 3

---

<div class="post-metadata">

**Author:** ![MBer](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@MBer](https://forums.balena.io/u/MBer)\
**Post date:** [May 30, 2020, 9:37pm UTC](https://forums.balena.io/t/timezone-troubles/122430/2 "2020-05-30T21:37:49Z")

</div>

How exactly did you follow the balena-timezone example?

It gives a script, start.sh, whose code writes the contents of TIMEZONE to [/etc/timezone](https://linux-audit.com/configure-the-time-zone-tz-on-linux-systems/) and calls an OS-level update. The script does not exist in other containers unless you add it. Is it being called? If so, are you seeing any errors in the container logs when those two lines run?

---

<div class="post-metadata">

**Author:** ![20k-ultra](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/20k-ultra/32/3435_2.png) [@20k-ultra](https://forums.balena.io/u/20k-ultra)\
**Post date:** [June 1, 2020, 5:46pm UTC](https://forums.balena.io/t/timezone-troubles/122430/7 "2020-06-01T17:46:43Z")

</div>

This repository illustrates configuring the timezone for an application not the OS (host). On Balena, each application is it’s own docker container so this example would have to be applied to each application’s dockerfile that would like a different TIMEZONE than UTC. We have [https://github.com/balena-io/docker-masterclass/](https://github.com/balena-io/docker-masterclass/) that can help explain how we use docker for applications.

Can you better describe how you’re testing if the timezone is correctly being changed? Is there a specific command or programming language you’re using ?

---

<div class="post-metadata">

**Author:** ![xginn8](https://avatars.discourse-cdn.com/v4/letter/x/8baadc/32.png) [@xginn8](https://forums.balena.io/u/xginn8)\
**Post date:** [June 10, 2020, 6:51pm UTC](https://forums.balena.io/t/timezone-troubles/122430/9 "2020-06-10T18:51:26Z")

</div>

Hi there,

I wanted to circle back here and see if you had any luck setting the local timezone in your container. If you are still having issues, please do reach out again!

---

<div class="post-metadata">

**Author:** ![mhoejgaard](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mhoejgaard](https://forums.balena.io/u/mhoejgaard)\
**Post date:** [November 1, 2020, 11:27am UTC](https://forums.balena.io/t/timezone-troubles/122430/11 "2020-11-01T11:27:55Z")

</div>

While developing a new app with Balena, I also had issues setting the timezone with [the example project](https://github.com/balena-io-examples/balena-timezone). It turns out that the approach needs to be slightly modified since it now requires a symlink as documented [here](https://bugs.launchpad.net/ubuntu/+source/tzdata/+bug/1554806).

This [PR](https://github.com/balena-io-examples/balena-timezone/pull/6) from August 2019 addresses the issue. Could the Balena team perhaps merge it?

As always, thanks for a great product and support!

---

<div class="post-metadata">

**Author:** ![pesant](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pesant/32/5681_2.png) [@pesant](https://forums.balena.io/u/pesant)\
**Post date:** [March 30, 2021, 4:42pm UTC](https://forums.balena.io/t/timezone-troubles/122430/12 "2021-03-30T16:42:59Z")

</div>

Hi there!

I tried creating an environment variable ‘TIMEZONE’ too with ‘Europe/Paris’ in a Screenly OSE Project and BalenaOS 2.73.1  
I thought everything works fine until today, the bad time is displayed in my webpage in UTC time again, for an unknown reason! I tried before to set the right timezone by that command line :

```
sudo rm /etc/localtime
sudo ln -s /usr/share/zoneinfo/Europe/Paris/etc/localtime

```

It seems I found the right things to do (install Git, clone the Balena-timezone project to the viewer Screenly container - timedatectl command doesn’t work because of not using systemd but chrony - I GUESS - and set Europe/Paris as default timezone by the following command) :

`sudo dpkg-reconfigure tzdata` (check World zone and city #8 and #37 for me)

after that… I restart the example project Balena-Timezone :

`bash start.sh` gives me that result :

**Setting time zone to Europe/Paris**

**Current default time zone: 'Europe/Paris’**  
**Local time is now: Tue Mar 30 18:41:03 CEST 2021.**  
**Universal Time is now: Tue Mar 30 16:41:03 UTC 2021.**

**Tue Mar 30 18:41:03 CEST 2021**

A kind of victory for me 😃

Hope this could help some people around 😕

---

<div class="post-metadata">

**Author:** ![vipulgupta2048](https://avatars.discourse-cdn.com/v4/letter/v/a183cd/32.png) [@vipulgupta2048](https://forums.balena.io/u/vipulgupta2048)\
**Post date:** [March 31, 2021, 12:32pm UTC](https://forums.balena.io/t/timezone-troubles/122430/17 "2021-03-31T12:32:00Z")

</div>

Hello,  
Thanks for reaching out. AFAIK, creating an environment variable `TIMEZONE` doesn’t work. Please try using `TZ` instead. We are in process of updating our documentation as well as clarifying it on the balena-timezone example README. `balena-timezone` example is no longer relevant as projects can instead set the `TZ` environment variable to set the timezone. Most of the balenaLabs project uses the same to set the timezone in the application. Here’s some more information regarding the same - [GitHub - balenalabs/inkyshot: Get a daily random inspirational quote delivered direct to your desk with Inkyshot. Build multiple Inkyshots and share the inspiration with your friends, family and loved ones ❤️](https://github.com/balenalabs/inkyshot#timezone)  
Let us know if this works out for you. Also, please do let us know where else the `TIMEZONE` env var has been referenced and help us update that both on our side and the Screenly OSE project. Thanks!

---

<div class="post-metadata">

**Author:** ![pesant](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pesant/32/5681_2.png) [@pesant](https://forums.balena.io/u/pesant)\
**Post date:** [March 31, 2021, 5:57pm UTC](https://forums.balena.io/t/timezone-troubles/122430/19 "2021-03-31T17:57:54Z")

</div>

> [@vipulgupta2048](#):
>
> creating an environment variable `TIMEZONE` doesn’t work

Hi Vipul,  
Thanx to answer back.

I don’t really know if it works or not by creating `TIMEZONE`. First, I created an environment variable as mentionned in the doc (not sure to remember). Anyway, it wasn’t what I expected.  
I thought it changed my logs with the right timezone and something happenned because services stopped and automatically restarted. UTC switch turned to grayed and off and TimeStamps too but the good (for me) was reading as variable I guess.!

 ![chrome_CTaGJJMyfv](https://global.discourse-cdn.com/balena/original/2X/b/be5d5bd9e4036fd83a0fef1adf33933ceab01e4b.png)

I tried `TZ` too as you can see in the picture below (`override` means or depends if I did it sometimes in DEVICE VARIABLES or sometimes in Application ENVIRONMENT VARIABLES, I guess…not sure too).

 ![chrome_nEOSb3o9XA](https://global.discourse-cdn.com/balena/original/2X/e/ee7399ac5cfda31a2ce934ae09389574ecfbb2af.png) ![chrome_vryDpDGLTw](https://global.discourse-cdn.com/balena/original/2X/f/f76196c9c76dab65c077f52920ec23152e9f3d12.png)

I don’t know exactly what behavior I had to expect. I was wrong, I thought it was a way to change in each docker/service/container ?! Probably silly to expect that! 🙂

I tried to change directly with command line and prompt terminal in HostOS to understand better what I’m allow to do…

 ![chrome_LreBR1mP2p](https://global.discourse-cdn.com/balena/original/2X/b/be4bb416ad6d4f1d06ded68fcf846e04de0cf4e5.png)

I finally tried to change in right place `srly-ose-viewer` because, I want to display the right time in France in front of webbrowser (HDMI ouput). By pushing balena-timezone here, i was avable to set Europe/Paris timezone (only UTC was able before), I set by the command `sudo dpkg-reconfigure tzdata` and after launching start.sh I saw everything goes fine like I want. And get what I expected in front user HDMI display.

 ![chrome_ZgRhel8aMY](https://global.discourse-cdn.com/balena/original/2X/e/e223d50a5d3d519a91c80f9e47bf69c217b5ad91.png)

I’m really sorry I’m a **real newbie** and discovering Python, Balena, RaspberryPi etc… It’s a new world for me, I hope I gave you a clear answer to your question - probably not 😃  
I started my project few days ago and I have to learn everything!!! Thanx for the link by the way and forgive my VERY BAD English…

> Let us know if this works out for you. Also, please do let us know where else the TIMEZONE env var has been referenced and help us update that both on our side and the Screenly OSE project. Thanks!

I read a lot those last few days to launch my project, not really sure about my sources.  
i correct myself because of this [Viewing/Setting Timezone - Balena - Anthias Forum](https://forums.screenly.io/t/viewing-setting-timezone/136)  
The timezone thing came fromt that [GitHub - balena-io-examples/balena-timezone: Example of how to set the timezone within a container](https://github.com/balena-io-examples/balena-timezone)  
I didn’t understand yet that [Time management | balena](https://www.balena.io/docs/reference/OS/time/)  
Chrony seems great but too complicated to me for now

I do not wish to take up too much of your time but do you know if someone in Balena Team could answer to my Cron question??  
Here —\> [CRON tasks question : Newb tries to launch simple project RPi4+BalenaOS/Cloud+Screenly](https://forums.balena.io/t/cron-tasks-question-newb-tries-to-launch-simple-project-rpi4-balenaos-cloud-screenly/279332)

**Thank you very much.**

---

<div class="post-metadata">

**Author:** ![nitish](https://avatars.discourse-cdn.com/v4/letter/n/34f0e0/32.png) [@nitish](https://forums.balena.io/u/nitish)\
**Post date:** [April 1, 2021, 2:19pm UTC](https://forums.balena.io/t/timezone-troubles/122430/21 "2021-04-01T14:19:56Z")

</div>

Thanks for the details here. If understand correctly, you were able to sort out the issue via use of `...reconfigure tzdata`.

Just as an input here. I see from your screenshot you set variable as `ENV` and then set the value as `TZ=<value>` instead you need to set the `TZ` as the name there and the corresponding `<value>` in the value field. Much like you have set `TIMEZONE` as the complete keyword. That would sort out the issue from the variable side.

Let us know once you try `TZ` standalone variable. We will in the interim take a look at your cron question.

---

<div class="post-metadata">

**Author:** ![pesant](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pesant/32/5681_2.png) [@pesant](https://forums.balena.io/u/pesant)\
**Post date:** [April 1, 2021, 4:06pm UTC](https://forums.balena.io/t/timezone-troubles/122430/23 "2021-04-01T16:06:10Z")

</div>

> [@nitish](#):
>
> Just as an input here. I see from your screenshot you set variable as `ENV` and then set the value as `TZ=<value>` instead you need to set the `TZ` as the name there and the corresponding `<value>` in the value field. Much like you have set `TIMEZONE` as the complete keyword. That would sort out the issue from the variable side.
> 
> Let us know once you try `TZ` standalone variable. We will in the interim take a look at your cron question.

Hi @nitish,

I saw it this morning and changed it, it works like a charm (everywhere I have the good timezone except in BalenaOS, still UTC)

Thanx to you!

 ![chrome_c6suMEBdGF](https://global.discourse-cdn.com/balena/original/2X/4/4b9d97db1807b6f7cb79ac631533b12721fe36d8.png)

 ![chrome_c6suMEBdGF](https://global.discourse-cdn.com/balena/original/2X/a/aff7e2c7148e4d9340f7836a5c35a34a3fed4e27.png)

> you were able to sort out the issue via use of `...reconfigure tzdata` .

Completly right, I saw it in Ubuntu doc and took my chance 😃 it worked too.

Have a nice day, thanx to have a look to my cron question!!!
