Cant get time set correctly

Forum for questions and support relating to the 1.32.x releases only.
Post Reply
iitywygms
Posts: 123
Joined: Thu Nov 08, 2012 5:19 am

Cant get time set correctly

Post by iitywygms »

Hi All:

Installed: 1.32.3-bionic
18.04 ubuntu

Installed using this link
https://wiki.zoneminder.com/Ubuntu_Serv ... e_easy_way

Worked fine for several days.
I then decided I wanted to make the time correct on my zoneminder server.
Did this. dpkg-reconfigure tzdata
After that, it all went down hill. Failure to authenticate user. no image. socket errors. + more

I noticed at that the time in the log files was wrong. So I tried to make zoneminder use the right time by updating the php.ini files like below.

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

I live in california

I found 2 php.ini and updated them both the same.

/etc/php/7.2/apache2/php.ini
/etc/php/7.2/cli/php.ini

But no matter what I do, the time is not shown correctly in zoneminder. Always 7 hours ahead.
I am not sure this is what is causing all my sudden issues, but would like to get the time reported by zoneminder correct to at least eliminate that as the problem.

What am I not doing correctly?

Thank you.
iitywygms
Posts: 123
Joined: Thu Nov 08, 2012 5:19 am

Re: Cant get time set correctly

Post by iitywygms »

Well solved it by purging and re installing zoneminder.
After new install all times were correct and no more errors.

Not sure why its fixed but it is.
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Cant get time set correctly

Post by knight-of-ni »

There are three timezones on your system that all have to match:
- The operating system
- php
- mysql

If all three do not match, exactly, you will have breakage.

Setting the timezone in the OS should be straight forward.

You also have to set the exact same timezone in your php.ini file. Debian users have the added complexity of multiple php.ini files. Your question regarding which php.ini you should change is answered in the same instructions you linked earlier.

The third timezone is the least obvious. Mysql also has a timezone setting and in some cases it does not automatically follow the OS timezone. There are different ways to set the timezone too. One can set the TZ variable or set time_zone in the mysql config. How you set this will vary by linux distro.

So basically, when you changed the time zone after installing zoneminder, you set the system timezone, but the timezone in php and/or mysql no longer matched.... hence the breakage.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
iitywygms
Posts: 123
Joined: Thu Nov 08, 2012 5:19 am

Re: Cant get time set correctly

Post by iitywygms »

Thank you for the info.
I installed zm while the system time was not correct. Which was my first mistake.

To try and fix it I did set the time in both php.ini files, so the time setting must have been wrong in mysql?
I purged the zm database when I did the re install. Perhaps reinstalling the zm database fixed the mysql part that was wrong?

Anyway, all good now. Thank you again.
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Cant get time set correctly

Post by knight-of-ni »

Even though you worked around the issue, I wanted to post the background behind what is happening and how to fix it, to help others. You are not the first person to run into this, and most certainly won't be the last.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
bbunge
Posts: 2931
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: Cant get time set correctly

Post by bbunge »

Just to add my $.02 on this, the install script you used reads the system time configuration (/etc/timezone) then appends the/etc/php/7.2/apache2/php.ini file with the time zone. This was done to save a bunch of manual edits during install. For most folks this is not an issue but when you start fiddling with settings after install things can break. Always best to set your time zone at OS install.
Glad you got it fixed!
aschouwe
Posts: 2
Joined: Thu Apr 20, 2023 1:28 am

Re: Cant get time set correctly

Post by aschouwe »

knight-of-ni wrote: Wed Dec 26, 2018 12:37 am There are three timezones on your system that all have to match:
- The operating system
- php
- mysql

If all three do not match, exactly, you will have breakage.

Setting the timezone in the OS should be straight forward.

You also have to set the exact same timezone in your php.ini file. Debian users have the added complexity of multiple php.ini files. Your question regarding which php.ini you should change is answered in the same instructions you linked earlier.

The third timezone is the least obvious. Mysql also has a timezone setting and in some cases it does not automatically follow the OS timezone. There are different ways to set the timezone too. One can set the TZ variable or set time_zone in the mysql config. How you set this will vary by linux distro.

So basically, when you changed the time zone after installing zoneminder, you set the system timezone, but the timezone in php and/or mysql no longer matched.... hence the breakage.
This helped me solve my UTC time on events issue! Thanks :D
murbe
Posts: 3
Joined: Sun Apr 30, 2023 10:38 am

Re: Cant get time set correctly

Post by murbe »

aschouwe wrote: Thu Apr 20, 2023 8:38 pm
knight-of-ni wrote: Wed Dec 26, 2018 12:37 am There are three timezones on your system that all have to match:
- The operating system
- php
- mysql

If all three do not match, exactly, you will have breakage.

Setting the timezone in the OS should be straight forward.

You also have to set the exact same timezone in your php.ini file. Debian users have the added complexity of multiple php.ini files. Your question regarding which php.ini you should change is answered in the same instructions you linked earlier.

The third timezone is the least obvious. Mysql also has a timezone setting and in some cases it does not automatically follow the OS timezone. There are different ways to set the timezone too. One can set the TZ variable or set time_zone in the mysql config. How you set this will vary by linux distro.

So basically, when you changed the time zone after installing gbwhatsapp, you set the system timezone, but the timezone in php and/or mysql no longer matched.... hence the breakage.
This helped me solve my UTC time on events issue! Thanks :D
Setting the timezone in the operating system is indeed straightforward and can be done through the system settings or configuration files.

Regarding PHP, the timezone can be set in the php.ini file. Depending on your Linux distribution, you may have multiple php.ini files, and you can refer to the instructions you mentioned earlier to determine which one to modify.

For MySQL, it's important to ensure that the timezone setting matches the desired timezone as well. This can be done by setting the time_zone parameter in the MySQL configuration file or by setting the TZ environment variable.
Post Reply