All Recorded Events are in UTC time no matter what I do

Discussions related to the 1.36.x series of ZoneMinder
ilovelunch
Posts: 2
Joined: Mon Feb 27, 2023 2:01 am

All Recorded Events are in UTC time no matter what I do

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

Image

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

Image

And my current Time settings on the Linux machine:

Image

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';
Image

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.

Image

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 :D
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: All Recorded Events are in UTC time no matter what I do

Post by Magic919 »

If it all looks ok, I'd generally say check the logs.
-
User avatar
iconnor
Posts: 3269
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: All Recorded Events are in UTC time no matter what I do

Post 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.
User avatar
iconnor
Posts: 3269
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: All Recorded Events are in UTC time no matter what I do

Post 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)
ilovelunch
Posts: 2
Joined: Mon Feb 27, 2023 2:01 am

Re: All Recorded Events are in UTC time no matter what I do

Post 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):

Image

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:

Image

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.
User avatar
iconnor
Posts: 3269
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: All Recorded Events are in UTC time no matter what I do

Post by iconnor »

That's really weird.
zmregs777
Posts: 1
Joined: Fri Jul 12, 2024 7:25 pm

Re: All Recorded Events are in UTC time no matter what I do

Post by zmregs777 »

Thank you very much!!!
Changing the LOCALE_DEFAULT setting to my local country/language finally solved the issue
bspiegel
Posts: 20
Joined: Wed Oct 22, 2014 7:54 pm

Re: All Recorded Events are in UTC time no matter what I do

Post 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.
dougmccrary
Posts: 1336
Joined: Sat Aug 31, 2019 7:35 am
Location: San Diego

Re: All Recorded Events are in UTC time no matter what I do

Post by dougmccrary »

MySql has time_zone=SYSTEM = UTC in linux.
bspiegel
Posts: 20
Joined: Wed Oct 22, 2014 7:54 pm

Re: All Recorded Events are in UTC time no matter what I do

Post 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.
dougmccrary
Posts: 1336
Joined: Sat Aug 31, 2019 7:35 am
Location: San Diego

Re: All Recorded Events are in UTC time no matter what I do

Post by dougmccrary »

Hmmm.
locale is set to UTC-8 for PST
Did you change this? Might take a reboot.
bspiegel
Posts: 20
Joined: Wed Oct 22, 2014 7:54 pm

Re: All Recorded Events are in UTC time no matter what I do

Post 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.
dougmccrary
Posts: 1336
Joined: Sat Aug 31, 2019 7:35 am
Location: San Diego

Re: All Recorded Events are in UTC time no matter what I do

Post 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.
bspiegel
Posts: 20
Joined: Wed Oct 22, 2014 7:54 pm

Re: All Recorded Events are in UTC time no matter what I do

Post 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?
bspiegel
Posts: 20
Joined: Wed Oct 22, 2014 7:54 pm

Re: All Recorded Events are in UTC time no matter what I do

Post 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.
Post Reply