Page 1 of 2
All Recorded Events are in UTC time no matter what I do
Posted: Mon Feb 27, 2023 2:29 am
by ilovelunch
Hey All,
Trust me on this one, I've looked up every single which way to fix this issue and I am totally lost.
First of all let me set the scene. I'm currently on version 1.36.33 using Linux 6.1.12-arch1-1 x86_64 GNU/Linux on Arch Linux. I installed this via the AUR and it's working fantastically.
Now the issue I'm running into is the fact that all the recordings are timestamped in UTC and it makes it super difficult to figure out when things happen, see example here:
Now I've made sure my Time and Date settings are set in the Options to my current location which is Australia/Hobart (which is going to be the same for everything I do):
And my current Time settings on the Linux machine:
So I did ye ole searching on the interwebs to see if anyone else has had this issue and I located this
viewtopic.php?t=22577 which I figured okay, lets check the MariaDB settings. From what I read in the MariaDB documentation, if you don't pass through the default-time-zone parameter in the my.cnf config file it just takes whatever the system is using.
This didn't help much because it's still posting all the recordings in UTC time so I edited the my.cnf file with the code:
Code: Select all
default-time-zone = "Australia/Hobart"
Initially this failed as I had to import all the Timezones using the following code:
Code: Select all
mysql_tzinfo_to_sql /usr/share/zoneinfo/ | mysql -u root mysql -p
After running that and verifying this actually did anything I consulted the MariaDB Documentation on Timezones here:
https://mariadb.com/kb/en/time-zones/
I ran the following 2 codes to per the documentation to see if the Global Server TIme Zone and the Session Time Zones are set correctly:
Code: Select all
SHOW GLOBAL VARIABLES LIKE 'time_zone';
and
SHOW SESSION VARIABLES LIKE 'time_zone';
Rebooted the Server and it stuck with it as it's defined in the my.cnf file however all the recordings even to this minute are still posted in UTC even though the Camera's Timestamps at the top right corner, specifically provided by Zoneminder is in the correct Time Zone and format.
Would love some insights as to how I can work around fixing this or if there's any suggestions anyone can provide me to further troubleshoot because I'm at complete loss.
Thanks and kind regards
Re: All Recorded Events are in UTC time no matter what I do
Posted: Mon Feb 27, 2023 9:47 am
by Magic919
If it all looks ok, I'd generally say check the logs.
Re: All Recorded Events are in UTC time no matter what I do
Posted: Tue Feb 28, 2023 2:30 pm
by iconnor
I've not seen that before.
When we do the event insert, we don't specify the tz.. around here, mysql just takes assumes it is in the tz.
I have never set the tz in mysql, I just let it default to the system tz. So I don't know if your messing about there has changed it's default behaviour.
Re: All Recorded Events are in UTC time no matter what I do
Posted: Tue Feb 28, 2023 2:31 pm
by iconnor
SHOW GLOBAL VARIABLES LIKE 'time_zone';
+---------------+--------+
| Variable_name | Value |
+---------------+--------+
| time_zone | SYSTEM |
+---------------+--------+
1 row in set (0.00 sec)
SHOW SESSION VARIABLES LIKE 'time_zone';
+---------------+--------+
| Variable_name | Value |
+---------------+--------+
| time_zone | SYSTEM |
+---------------+--------+
1 row in set (0.00 sec)
Re: All Recorded Events are in UTC time no matter what I do
Posted: Wed Mar 01, 2023 7:45 am
by ilovelunch
Thanks for the responses, very much appreciate you guys looking into this
If I remove the hard coded variable in the my.cnf file and run the SHOW commands, it does indeed default to SYSTEM for the Variable_name table however you are right this does not change the behavior of the timestamps and still reports them as UTC within Zoneminder so it seems fruitless to change the timezones manually.
Changed the logs to debugging to see if I could locate anything strange going on but I found this SQL query to be interesting (also to note all the logs are stored in UTC time as well):
So I use webmin as it's much easier to traverse a SQL DB for me this way and attempted to locate the events and interestingly enough they are placed into the Database correctly with the correct timezone:
Is there anything else you can think of for me to check?
--------------------
I fixed it... I cannot believe it was this simple. All I did was change the LOCALE_DEFAULT setting in the system settings to en_AU and now all the timestamps are showing correctly with the correct timezones. Checking on the Arch box itself with locale -a it results in these 3 locales:
C.UTF-8
en_AU.utf8
en_US.utf8
I'm not really sure which locale Zoneminder chose to use but manually setting it within the ZM settings fixed the issue.
Re: All Recorded Events are in UTC time no matter what I do
Posted: Wed Mar 01, 2023 11:25 pm
by iconnor
That's really weird.
Re: All Recorded Events are in UTC time no matter what I do
Posted: Fri Jul 12, 2024 7:28 pm
by zmregs777
Thank you very much!!!
Changing the LOCALE_DEFAULT setting to my local country/language finally solved the issue
Re: All Recorded Events are in UTC time no matter what I do
Posted: Sun Dec 29, 2024 5:19 pm
by bspiegel
I am experiencing a similar issue. Ver 1.36.35 on Ubuntu 24.04. The problem is all events are UTC and not my time zone.
MySql has time_zone=SYSTEM.
locale is set to UTC-8 for PST.
Zoneminder is America/Los Angeles.
Nothing in mysql.cnf.
Rebooted the system.
I am at a loss as to what might be causing this.
Re: All Recorded Events are in UTC time no matter what I do
Posted: Tue Dec 31, 2024 2:15 am
by dougmccrary
MySql has time_zone=SYSTEM = UTC in linux.
Re: All Recorded Events are in UTC time no matter what I do
Posted: Tue Dec 31, 2024 3:24 am
by bspiegel
Thanks.
I changed mysql as follows:
Loaded the timezones using mysql_tzinfo_to_sql.
set time_zone='America/Los_Angeles';
set global time_zone='America/Los_Angeles';
restarted mysql and zoneminder
I triggered an event, and it's still using UTC date.
Re: All Recorded Events are in UTC time no matter what I do
Posted: Tue Dec 31, 2024 3:48 am
by dougmccrary
Hmmm.
locale is set to UTC-8 for PST
Did you change this? Might take a reboot.
Re: All Recorded Events are in UTC time no matter what I do
Posted: Tue Dec 31, 2024 4:53 am
by bspiegel
locale was set to UTC-8 when I installed linux. All the times displayed by linux and apps are correct. Just have an issue with zoneminder.
Re: All Recorded Events are in UTC time no matter what I do
Posted: Tue Dec 31, 2024 7:37 am
by dougmccrary
Options->System->LOCALE_DEFAULT = System Default ?
Options->System->TIMEZONE = (GMT-08:00) AMERICA, some city ?
And if those are right, I give up, if one of those isn't it. Sorry if so.
Re: All Recorded Events are in UTC time no matter what I do
Posted: Tue Dec 31, 2024 3:17 pm
by bspiegel
I am running xubuntu 24.04 and don't see these settings (Options->System->LOCALE_DEFAULT).
I played around with mysql a bit, from other google searches.
mysql> SELECT @@SYSTEM_TIME_ZONE, @@TIME_ZONE, @@global.time_zone, NOW();
+--------------------+-------------+--------------------+---------------------+
| @@SYSTEM_TIME_ZONE | @@TIME_ZONE | @@global.time_zone | NOW() |
+--------------------+-------------+--------------------+---------------------+
| PST | SYSTEM | SYSTEM | 2024-12-31 06:53:23 |
+--------------------+-------------+--------------------+---------------------+
Using mysql, I set time_zone and global time_zone, but on exit, they reset to SYSTEM.
I changed the mysql.cnf file to add:
[mysqld]
default-time-zone='America/Los_Angeles'
Restarted mysql
Now it reports correctly:
mysql> SELECT @@SYSTEM_TIME_ZONE, @@TIME_ZONE, @@global.time_zone, NOW();
+--------------------+---------------------+---------------------+---------------------+
| @@SYSTEM_TIME_ZONE | @@TIME_ZONE | @@global.time_zone | NOW() |
+--------------------+---------------------+---------------------+---------------------+
| PST | America/Los_Angeles | America/Los_Angeles | 2024-12-31 07:05:02 |
+--------------------+---------------------+---------------------+---------------------+
However, zoneminder still reports UTC.
Ran$ timedatectl
Local time: Tue 2024-12-31 07:16:16 PST
Universal time: Tue 2024-12-31 15:16:16 UTC
RTC time: Tue 2024-12-31 15:16:16
Time zone: America/Los_Angeles (PST, -0800)
System clock synchronized: yes
NTP service: n/a
RTC in local TZ: no
Ideas?
Re: All Recorded Events are in UTC time no matter what I do
Posted: Tue Dec 31, 2024 3:30 pm
by bspiegel
Solved!
I modified /etc/php/8.3/apache2/php.ini which had no timezone set. Added:
date.timezone = "America/Los_Angeles"
I restarted apache2 and zonemidner started reporting the correct date/time.