Jump to content

Recommended Posts

Posted

This refers to the issue posted here: https://processwire.com/talk/topic/30845-solved-database-time-vs-php-time/ 

However I've posted a new topic because the above topic was marked solved by the OP.

I'm getting the same error:

  • Warning, the database time differs from PHP time by 8 hours.

    2025-02-12 09:51:44 - database time
    2025-02-12 17:51:44 - PHP time

    Please edit your /site/config.php file and update your $config->timezone to match that of your database. See PHP timezones list

My MySQL installation has to remain set to UTC, because it serves various sites in various timezones.

I learned here: https://stackoverflow.com/questions/19023978/should-mysql-have-its-timezone-set-to-utc/19075291 that I can set the session timezone in MySQL, with this command, which I think will solve my problem:

SET @@session.time_zone = "+08:00";

My question is, from which ProcessWire file should I execute this, in order for it to prevent the above warning? site/templates/_init.php or somewhere else?

Thanks in advance.

 

Posted

Hi @DrewPH

Put the following line into your config.php

$config->dbInitCommand = "SET NAMES '{charset}', time_zone = '-08:00' ";

Adjust the timezone according to your need.

Gideon

 

  • Like 3
Posted

I found that all I needed at the end of my config.php was 

$config->dbInitCommand = "SET time_zone = '+08:00' ";

and all is good, warning gone. Thanks again.

  • Like 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...