Timezone Troubles

I’ve been trying to setup timezones but it does not seem to work.
Following this, 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

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 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?

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/ 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 ?

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!

While developing a new app with Balena, I also had issues setting the timezone with the example project. It turns out that the approach needs to be slightly modified since it now requires a symlink as documented here.

This PR from August 2019 addresses the issue. Could the Balena team perhaps merge it?

As always, thanks for a great product and support!

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

Hope this could help some people around :confused:

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 ❤️
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!

1 Like

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.!

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).

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! :slight_smile:

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

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.

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 :smiley:
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
The timezone thing came fromt that GitHub - balena-io-examples/balena-timezone: Example of how to set the timezone within a container
I didn’t understand yet that Time management - Balena Documentation
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

Thank you very much.

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.

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!

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 :smiley: it worked too.

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