How to show local time (instead of UTC) in events-list?

Discussions related to the 1.36.x series of ZoneMinder
Post Reply
User avatar
danielmalaga
Posts: 15
Joined: Sun Nov 07, 2021 12:09 pm
Location: Málaga, Spain
Contact:

How to show local time (instead of UTC) in events-list?

Post by danielmalaga »

Hi,

All videos are saved with the correct local time (UTC+2.00), also the inserted time in the snapshot pictures show the correct local time, but in the events list start/end-time show UTC time.

Where/how do I set that the local times are displayed?

(
ZM-options TIMEZONE is set to "(GMT+02:00) Europe, Madrid"; MySQL timezone is set the same
as said, ZM obviously knows the local time as it inserts the correct local time into snapshot images
I think it must be a display setting have I missed
)

Can you hint me in the right direction?
Thanks!
bbunge
Posts: 2975
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: How to show local time (instead of UTC) in events-list?

Post by bbunge »

Best way to fix this is to add the timezone to php.ini

This example is for Debian 12

Add timezone to PHP (This may not be necessary but does not hurt and will allow the time of events to be displayed correctly)

nano /etc/php/8.2/apache2/php.ini

Search for [Date] (Ctrl + w then type Date and press Enter) and make changes as follows for your time zone

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = America/New_York

Ctrl+o Enter to save

CTRL+x to exit

Restart Apache

service apache2 restart
User avatar
danielmalaga
Posts: 15
Joined: Sun Nov 07, 2021 12:09 pm
Location: Málaga, Spain
Contact:

Re: How to show local time (instead of UTC) in events-list?

Post by danielmalaga »

SOLVED.

Thank you very much, bbunge!

Changing date.timezone in php.ini did the trick. Times are now displayed in my local time.
dougmccrary
Posts: 1370
Joined: Sat Aug 31, 2019 7:35 am
Location: San Diego

Re: How to show local time (instead of UTC) in events-list?

Post by dougmccrary »

Curious -
Did you not get a prompt at (initial) setup time to set Options->System->TIMEZONE?
User avatar
danielmalaga
Posts: 15
Joined: Sun Nov 07, 2021 12:09 pm
Location: Málaga, Spain
Contact:

Re: How to show local time (instead of UTC) in events-list?

Post by danielmalaga »

I am not sure if there was a prompt or if I set it up according to my old setup on my last install on another machine.

Anyway, Options->System->TIMEZONE is/was set correct, and this was not the problem. The problem was that in php.ini date.timezone was set to 'UTC' instead of 'Europe/Madrid' (in my case)
dougmccrary
Posts: 1370
Joined: Sat Aug 31, 2019 7:35 am
Location: San Diego

Re: How to show local time (instead of UTC) in events-list?

Post by dougmccrary »

Interesting.
Thanks.
anndrew
Posts: 12
Joined: Tue Nov 26, 2024 11:02 am

Re: How to show local time (instead of UTC) in events-list?

Post by anndrew »

Thank you, it worked for me too (currently using Zoneminder 1.36.35 under Debian 12-bookworm as well).
For those who - like me - might miss the final lines of the solution message, don't forget to restart apache2 for the change to take effect, for example like this:

Code: Select all

sudo systemctl restart apache2
Zotter
Posts: 7
Joined: Wed Oct 31, 2018 8:06 pm

Re: How to show local time (instead of UTC) in events-list?

Post by Zotter »

Just had to do a clean install as I'd been negligent in upgrading my base OS and it did bad things to itself

ZM V.1.36.35 on brandie new install of Fedora 42 Server - nothing else installed or running on that box

Local time zone was set on install, all events are displayed with UTC time stamps, while the in image 'timestamp' is local.

Just did set the timezone in php.ini and restarted apache and zoneminder.
Very next event a few minutes after restart showed as UTC in the event display with no change to the in image timestamp.

Looking for more suggestions on getting local time in the event window instead of UTC.

Note OS is set to local timezone as well

Code: Select all

# timedatectl
               Local time: Tue 2025-05-06 13:15:18 MDT
           Universal time: Tue 2025-05-06 19:15:18 UTC
                 RTC time: Tue 2025-05-06 19:15:18
                Time zone: America/Denver (MDT, -0600)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
Screenshot From 2025-05-06 13-09-23.png
Screenshot From 2025-05-06 13-09-23.png (923.02 KiB) Viewed 1403 times
Zotter
Posts: 7
Joined: Wed Oct 31, 2018 8:06 pm

Re: How to show local time (instead of UTC) in events-list?

Post by Zotter »

I've also imported the zone data directory into Mariadb as outlined here: https://mariadb.com/kb/en/mariadb-tzinfo-to-sql/

I used

Code: Select all

mariadb-tzinfo-to-sql /usr/share/zoneinfo | mariadb -u root mysql
Then I set the Mariadb timezone using

Code: Select all

SET GLOBAL time_zone = 'America/Denver';
(using the SET GLOBAL will not persist with a MariaDB restart - have to do a config file for that. Didn't bother for testing here)

Result

Code: Select all

MariaDB [(none)]> SHOW GLOBAL Variables LIKE 'time_zone';
+---------------+----------------+
| Variable_name | Value          |
+---------------+----------------+
| time_zone     | America/Denver |
+---------------+----------------+
1 row in set (0.001 sec)
Then restarted apache and zoneminder

No change on the UTC vs local timestamps in the event window and correct timestamps in the event images themselves.
Zotter
Posts: 7
Joined: Wed Oct 31, 2018 8:06 pm

Re: How to show local time (instead of UTC) in events-list?

Post by Zotter »

Had a power outage - again, my fault for not using a large enough UPS - but now, all the event times are showing MDT instead of UTC. So, seems the whole thing DOES need a re-boot to implement what I'd read to do, and then did, to correct things. Not just restart apache and zoneminder, but reboot the whole box. It's good now.
Post Reply