Local time vs Mysql time causing publishDate issue

11 posts by 6 authors in: Forums > CMS Builder
Last Post: January 18, 2021   (RSS)

By zip222 - December 9, 2020

I recently updated a site to v 3.54 and I am experiencing a problem with publishDates which seems to stem the timezone setting in General Settings. I have the timezone set to my local timezone, which then displays local time and mysql time to be 2 hours apart (see attachment). This leads to items using the publishDate field to not appear on the site until 2 hours after intended. 


timezone-settings.png 26K

By KennyH - December 10, 2020

To add onto this, I think a similar issue is causing problems in the Developer Log (3.54). It is saying errors are happening "In the future" instead of "XX seconds ago" or something similar.

By zip222 - December 17, 2020

Any thoughts on this?

By hans - December 21, 2020 - edited: December 21, 2020

Hello, I'll be looking over this issue.

Feel free to look over at lib/database_functions.php and find the setMySqlTimezone($timeZone) at around line 213, and you can manually set the timezone from there.

The format in coding is +00:00 where +00 equals the number of timezones to the left/right of the GMT. Based on your original post, you would have it as -05:00.

Hans Marcon
PHP Programmer (In Training)

By hans - December 21, 2020 - edited: December 21, 2020

Upon further research, it turns out that the above solution does not actually change the current timezone, if your MySQL is using the "SYSTEM" timezone. Unfortunately, this is very likely the case.

The next step in changing this would be to change it via your server's time, but this option varies based on your host's control panel. What control panel do you use for your hosting?

If it is cPanel, you can find instructions on how to change your server time here (https://docs.cpanel.net/whm/server-configuration/server-time/).

Hans Marcon
PHP Programmer (In Training)

By mark99 - January 7, 2021

I'm seeing the same issue. Luckily nothing we post is strictly time dependent, but obviously it's not ideal if the system can't adjust correctly to a set time or daylight saving times. Changing the server time is not something we have control over, so it needs to be fixable via CMSB.

By hans - January 7, 2021

Just to clarify, this is only a CMSB 3.5.4 issue, and not a 3.5.0 issue and below.

Hans Marcon
PHP Programmer (In Training)

By zip222 - January 7, 2021

Confirming that my installation, which is having this issues, is 3.54

By Dave - January 18, 2021

Hi All, 

We've fixed this bug for the next release.  Here's some instructions if you want to manually patch your current version:

  • Backup /lib/database_functions.php
  • Edit /lib/database_functions.php and search for mysqli($mysqli) 
  • Add the code in red: 

mysqli($mysqli); // save object on successful connection

// set connected flag

Let me know if that doesn't resolve the issue for you or if you need anything else.


Dave Edis - Senior Developer