sonoff-hack icon indicating copy to clipboard operation
sonoff-hack copied to clipboard

Wrong time displayed while correct timezone is set

Open flreinhard opened this issue 9 months ago • 4 comments

How can you see the error?

Time in snapshot, rtspstream and on commandline wrong. In my case it's 15:00:00 in the stream/picture, but in real it's 16:00:00

requirements

  • ntp server is setup and sync is working
  • timezone configured (in my case Europe/Brussels)
  • Firmware V5520.2053.0505build20230320, fix won't work with V5520.2053.0412build20220905

what i think is wrong

if you call date it will rely on /etc/TZ which is a symlink to /tmp/TZ to make a localtime from UTC. Must be something custom in the glibc that got shipped with the camera. Now in my case the content is EST+0:00:00 which is wrong in two different ways:

  1. it does not match my timezone
  2. the format is utterly wrong, gnu.org has the details

Since i live in CET Timezone which is UTC+1 the content should be CET-1 Works for me in theory and real life: Broken:

root@TestCam]# cat /etc/TZ 
EST+0:00:00
[root@TestCam]# date
Fri Mar 21 21:32:12 EST 2025
[root@TestCam]# date -u
Fri Mar 21 21:32:14 UTC 2025

Now let's fix it:

[root@TestCam]# echo "CET-1" > /etc/TZ 
[root@TestCam]# date
Fri Mar 21 22:33:16 CET 2025
[root@TestCam]# date -u
Fri Mar 21 21:33:19 UTC 2025

Is it only me having that issue because i refused to configure the camera with ewelink? What's your contents of /etc/TZ?

flreinhard avatar Mar 21 '25 21:03 flreinhard

This problem doesn't change if you configure the app with ewelink. The file /etc/TZ is created by colink or devctrl (I don't remember exactly) reading the timezone table in the db. And the db is set by the app and the web page (both).

Could you run these commands?

sqlite3 /mnt/mtd/db/ipcsys.db "select c_param_value from t_sys_param where c_param_name='ZoneTimeName';"
sqlite3 /mnt/mtd/db/ipcsys.db "select * from t_zonetime_info;"

I set Europe/Amsterdam and my time is ok.

roleoroleo avatar Mar 25 '25 20:03 roleoroleo

I haven't upgraded to 0.18 yet, so maybe my experience will be different than yours. I live in UTC-8 but found I had to set the timezone to UTC+8 (Asia/Hong_Kong) in order to get the correct local time. There is likely a backwards subtraction going on somewhere, but I've never spent any time trying to find it.

bob-cook avatar Apr 05 '25 04:04 bob-cook

Please, update to the last version and try again.

roleoroleo avatar Apr 05 '25 15:04 roleoroleo

NEW INFO: Updated to 0.18 this morning, timezone issue appears to be resolved, at least for my issue of UTC-8 vs. UTC+8.

bob-cook avatar Apr 05 '25 16:04 bob-cook

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jul 07 '25 03:07 github-actions[bot]