At my device, we would like to show local time to user.
Basically, we will fill current time with OSD on video stream.
But, we found the the video stream always show UTC time.
I double check the /etc/config/system, set 'CST-8' to option timezone and reload_config, /etc/TZ is correct. But, video stream still show UTC time.
My questions:
Is there a good way to make sure video stream always show local time instead of UCT time?
Is it possible without restart my video stream and OSD always show correct local time even if I apply new timezone?
A bit lost here what is the relation between Openwrt and your video stream?
Can you try to explain a bit more how you believe there is a relation between a time shown in a video stream and your router (openwrt)?
My device has USB port. We plugin USB camera and use V4L2 to capture video frames. Openwrt already provides mjpg-streamer at WebUI. We add a little bit changes before sending out the video frames, we put timestamp on each jpeg. The timestamp is created by gettimeofday(). Thanks.
Oops, ntp.pool.com is my internal ntp server, it works well.
Anyway, I change ntp server to standard.
root@OpenWrt:/# uci export system
package system
config system
option hostname 'OpenWrt'
option ttylogin '0'
option log_size '64'
option urandom_seed '0'
option timezone 'CST-8'
config timeserver 'ntp'
option enabled '1'
option enable_server '0'
list server '0.openwrt.pool.ntp.org'
root@OpenWrt:/# date -u
Fri Nov 6 01:06:41 UTC 2020
root@OpenWrt:/# date
Fri Nov 6 01:06:43 UTC 2020
And, my question still over there. Please check. Thanks.
root@OpenWrt:/etc/nginx# uci export system
package system
config system
option hostname 'OpenWrt'
option ttylogin '0'
option log_size '64'
option urandom_seed '0'
option timezone 'UTC-6'
config timeserver 'ntp'
option enabled '1'
option enable_server '0'
list server '0.openwrt.pool.ntp.org'
root@OpenWrt:/etc/nginx# date -u
Fri Nov 6 01:53:26 UTC 2020
root@OpenWrt:/etc/nginx# date
Fri Nov 6 01:53:28 UTC 2020
Yes, I use zoneinfo. But, we don't want to set zonename in /etc/config/system. We would like to try TZ base first.
zoneinfo packages is not installed (= the usual default), the POSIX compliant timezone string is used by musl libc. /etc/TZ is used as string storage.
zoneinfo packages are installed (e.g. zoneinfo-europe for me), the zonename option is used to fetch the info from zoneinfo database files based on zone name. There is no /etc/TZ or /tmp/TZ
If feel that you should set both options, just in case.
That shows the combination of values (zonename, timezone string) that can be set to the config file. Note that Musl libc actually parses the options without any knowledge of this table, but the table just shows a summary of the normal zoneinfo contents (and has grabbed POSIX strings from there))
Sorry, I should say I already use zoneinfo at my device to try.
But, I think it is not suitable to my case.
Basically, I prefer use env TZ to get correct local time.
I think I need to export TZ to each daemons if it needs the local time.
For now, I'm interested on if my daemon can auto apply new TZ env when I apply new timezone to system uci config? Do you have experiences on it?
Thanks a lot.
root@OpenWrt:/# cat /etc/TZ
CST-8
root@OpenWrt:/# echo $TZ
root@OpenWrt:/# date -u
Fri Nov 6 08:24:48 UTC 2020
root@OpenWrt:/# date
Fri Nov 6 08:24:49 UTC 2020
root@OpenWrt:/# export TZ=$(cat /etc/TZ)
root@OpenWrt:/# echo $TZ
CST-8
root@OpenWrt:/# date -u
Fri Nov 6 08:25:11 UTC 2020
root@OpenWrt:/# date
Fri Nov 6 16:25:12 CST 2020
And I will check if C function musl support or not on my device. Thanks.