CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Internationalization and Localization (Moderators: Michał Mach, mathieu) »
  • <solved>Timestamps reported by MySQL and PHP are mismatched
Pages: [1]

Author Topic: <solved>Timestamps reported by MySQL and PHP are mismatched  (Read 8577 times)

marchelo2212

  • I’m new here
  • *
  • Posts: 28
  • Karma: 2
  • CiviCRM version: 4.4.3
  • CMS version: Joomla 3.2
  • MySQL version: MySQL 5.5.32
  • PHP version: 5.3.26
<solved>Timestamps reported by MySQL and PHP are mismatched
September 03, 2014, 07:38:10 am
Hello everyone ...
I installed CiviCRM and at first it was all right but a few months ago this message is appearing me ...

"Reported by MySQL Timestamps (eg" 03/09/2014 10:31 ") and PHP (eg" 9/3/2014 9:31 ") are mismatched."

The correct time is to load from Joomla PHP (I think) ... my time zone is -5 gtm (Guayaquil / Ecuador - Bogota / Colombia).

Has someone happens something similar ..? .. How I can fix it?

Thanks a lot!

Marcelo
« Last Edit: October 16, 2014, 01:04:01 pm by marchelo2212 »

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Timestamps reported by MySQL and PHP are mismatched
September 04, 2014, 12:03:50 am
There are some helper function in CRM/Utils/Date.php, you could use those functions?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Timestamps reported by MySQL and PHP are mismatched
September 04, 2014, 12:39:03 am
A couple of questions.

Did this appear after an upgrade?

Have you checked how the timezones are set up in your MySQL and PHP configuration?

This check was introduced around April this year (see https://github.com/civicrm/civicrm-core/commits/6978ebe07ecc2336ab9b12ee9872d81ef961c740/CRM/Utils/Check/Env.php for details if you want).

I think you need to ensure that MySQL and PHP are using the same timezone.
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

marchelo2212

  • I’m new here
  • *
  • Posts: 28
  • Karma: 2
  • CiviCRM version: 4.4.3
  • CMS version: Joomla 3.2
  • MySQL version: MySQL 5.5.32
  • PHP version: 5.3.26
Re: Timestamps reported by MySQL and PHP are mismatched
September 08, 2014, 12:22:01 pm
Hi..!! thanks a lot for your answers!

Yes, I made an upgrade version and appearing this message.

I don't know where is the problem, if is when php transform "timestamps":
administrator/components/com_civicrm/civicrm/CRM/Utils/System/Base.php.

this is a several problem..? some time ago don't show me any message, and I have not changed any settings.


Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Timestamps reported by MySQL and PHP are mismatched
September 09, 2014, 02:04:51 am
http://wiki.civicrm.org/confluence/display/CRMDOC/checkMysqlTime gives some detail of what to look for (linked in that warning message).  There are three possible problems
Quote
    PHP and MySQL may be running on different servers, and the clocks may be out-of-sync. Configuring automatic clock synchronization is the best solution.
    PHP, MySQL, and/or the operating system may be configured to use different default timezones. Verify the configuration of each.
    The content management system (Drupal, Joomla, or WordPress) or one of its plugins may manipulate the timezone settings without CiviCRM's awareness. You may wish to post to the CiviCRM Forum about your problem. Please include any available details about the timezone settings in the operating system, PHP, MySQL, and the CMS; if you have any special CMS plugins or configuration options which may affect timezones, please report them.

So it could be any three of the above. Who does your hosting?  Is it a server/VPS/similar that you have configured? Or is it a third party service with a cpanel/webmin type interface?

That would help us work out which of the above is more likely. Do you have a sysadmin that is able to help with this?
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Timestamps reported by MySQL and PHP are mismatched
October 04, 2014, 01:06:22 am
I've seen this message on one my sites recently. Interestingly I have several Civi installs on the same VPS and they don't all show the notice, which i would expect them to as they are using the same resources.
Would be good to include some guidance for non-sysadmins as to how go about resolving this issue, if indeed it is an issue.
Graham Mitchell
http://mc3.coop

Dan C

  • I post frequently
  • ***
  • Posts: 179
  • Karma: 17
  • CiviCRM version: All
  • CMS version: Joomla 2.5 and 3.X, Drupal 7, Wordpress 3.7 and up
  • MySQL version: 5.1.7 and up
  • PHP version: 5.3.5 and up
Re: Timestamps reported by MySQL and PHP are mismatched
October 04, 2014, 04:21:37 am
I have had the same thing, one site of several in the same environment showing the message.  It turned out that site had a customized php.ini file that was overriding the default timezone on the servers PHP install (it was a legacy site that we inherited).  Unfortunately when that is the problem, there isn't a way to fix it other than editing the php.ini file.  This is one of those problems that unfortunately typically requires a sysadmin to fix, unless it is a case where the timezone is being set by the CMS in which case it can probably be fixed through the administrator interface of the CMS.
CrusonWeb - Web Development, Implementation, and Support.  Specializing in CiviCRM and Joomla (although also knowledgable in Wordpress and Drupal as well).

marchelo2212

  • I’m new here
  • *
  • Posts: 28
  • Karma: 2
  • CiviCRM version: 4.4.3
  • CMS version: Joomla 3.2
  • MySQL version: MySQL 5.5.32
  • PHP version: 5.3.26
Re: Timestamps reported by MySQL and PHP are mismatched
October 15, 2014, 09:42:59 am
according civicrm the possibilities about this problem are ...
Some plugins can modify the time line...... well I installed a new Joomla with civi but the messaje (time MySQL and PHP) continue.
Other possibility is MySQL and PHP are in different server... In my case, I think no because these are in the same server (I am correctly).

My hosting service is shared, I have a cpanel interface, I sent a message to the support service, these are the messagess:
Support:
We were able to set the desired time for PHP by adding the following line to your global php.ini:
date.timezone = "America/Guayaquil"

An .htaccess was also placed in the /www/www/web folder with the following line in it:
SetEnv TZ
Now, the CiviCRM reports the following message:
Timestamps reported by MySQL (eg "2014-09-02 13:22") and PHP (eg "2014-09-02 12:22" ) are mismatched.
Read more about this warning

Basically, the CiviCRM is loading the server's default MySQL time, which is in the EDT time zone, while the PHP has been correctly set to America/Guayaquil.

You should be able to resolve the issue by correcting the time zone in your CiviCRM installation. Unfortunately, as this installation is in Spanish, we were not able to locate the setting in question.

Me
I searched the time zone option but CIVICRM don't have this, only can modify the format date.
CiviCRM has my time zone, because the message has my time (Joomla - PHP).
You can change the time zone in MySQL..??

Suppor
Unfortunately, the default time zone of the MySQL server cannot be changed. Actually, the time zone of MySQL should not matter. A properly working script would simply convert the timestamps when reading/writing data to the MySQL database. CiviCRM should be automatically doing this as well. You could ask on their forums for the reasons why this warning is displayed. Are the timestamps displayed incorrectly in CiviCRM?
We found code that takes care of automatically converting timestamps with the required time zone offset in /home/prenatal/www/www/web/administrator/components/com_civicrm/civicrm/CRM/Utils/System/Base.php.


well.... can you help me...?? What are the lines to modify..? ??? ??? ???
my file php.ini has these lines:
date.timezone = "America/Guayaquil"   

danc   can you show me the lines of your php.ini...?


Dan C

  • I post frequently
  • ***
  • Posts: 179
  • Karma: 17
  • CiviCRM version: All
  • CMS version: Joomla 2.5 and 3.X, Drupal 7, Wordpress 3.7 and up
  • MySQL version: 5.1.7 and up
  • PHP version: 5.3.5 and up
Re: Timestamps reported by MySQL and PHP are mismatched
October 15, 2014, 03:31:49 pm
I had to remove the date.timezone setting from the php.ini file so that the PHP and MySQL timezones would match (so I can't show you it because it doesn't exist).  However, that is basically what support told you.  If your MySQL timezone is Eastern like they say then your php.ini line would need to be date.timezone = "America/New_York" which would force PHP to match the MySQL server and the error will disappear. 

I'm not sure why Civi requires the two to match instead of forcing them to.  I'm sure it was thought out but someone who was part of the discussion should chime in on that.
CrusonWeb - Web Development, Implementation, and Support.  Specializing in CiviCRM and Joomla (although also knowledgable in Wordpress and Drupal as well).

marchelo2212

  • I’m new here
  • *
  • Posts: 28
  • Karma: 2
  • CiviCRM version: 4.4.3
  • CMS version: Joomla 3.2
  • MySQL version: MySQL 5.5.32
  • PHP version: 5.3.26
<solved>Re: Timestamps reported by MySQL and PHP are mismatched
October 16, 2014, 01:03:13 pm
danc
 I did not removed the time zone but your words help me....

Olny change the time zone_:
date.timezone = "America/Guayaquil"
to
date.timezone = "America/New_York"
Now the problem is solved.

Thanks a lot
Marcelo

bcambon

  • I’m new here
  • *
  • Posts: 7
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Wordpress 4.1.1
  • MySQL version: 5.5
  • PHP version: 5.2.9
Re: <solved>Timestamps reported by MySQL and PHP are mismatched
June 01, 2015, 12:47:17 pm
Hi,

Following your instructions to solve this problem,
and adding information especially for wordpress/civixrm users...

"php.ini" is this file:
/www/wp-settings.php

You have to change "date_default_timezone_set( 'UTC );" by your localisation
eg: date_default_timezone_set( 'Europe/Paris' );

Hope it's useful for some of you.

This instruction seems to solve my problem.

Bests regards

tristanbradley

  • I’m new here
  • *
  • Posts: 1
  • Karma: 0
  • CiviCRM version: 4.7.2
  • CMS version: Drupal 7.43
  • MySQL version: 5.1.73
  • PHP version: PHP 5.3.29
Re: <solved>Timestamps reported by MySQL and PHP are mismatched
March 09, 2016, 09:02:18 am
Drupal 7.43
CiviCRM 4.7.2

Server Time EST
My Time UTC (GMT in London)

This was driving me a bit potty - managed to fix it by going to:
/admin/config/regional/settings

and setting the Default Time Zone to UTC (right at the bottom of the list) - fixed everything for me.

Might be worth a try.

vtitarchuk

  • I’m new here
  • *
  • Posts: 16
  • Karma: 1
  • Expert in Development of Educational Technologies
    • ServanTek Ukraine
  • CiviCRM version: 4.1
  • CMS version: Drupal
Re: <solved>Timestamps reported by MySQL and PHP are mismatched
April 22, 2016, 04:48:46 am
I had similar issue. It was solved, but here is the story.

MySql time stamp was posted properly. Then I checked the php.ini and corrected the config setting to my time zone.

The issue did not go away until I properly set the time in the WordPress settings: wp-admin/options-general.php

MAMP 3.5
CiviCRM 4.7
WordPress 4.5
Customizing CiviCRM for non-profits is the former Soviet Union
Localizing CiviCRM into Russian
Deploying CiviCRM in multi-lingual and multi-organizational environments
http://servantek.org.ua

drupleg

  • I post occasionally
  • **
  • Posts: 39
  • Karma: 2
    • Drupal.org Profile
  • CiviCRM version: 4.1
  • CMS version: Drupal 7
  • PHP version: 5.3
Re: <solved>Timestamps reported by MySQL and PHP are mismatched
April 26, 2016, 10:19:25 am
Quote from: tristanbradley on March 09, 2016, 09:02:18 am
Drupal 7.43
CiviCRM 4.7.2

Server Time EST
My Time UTC (GMT in London)

This was driving me a bit potty - managed to fix it by going to:
/admin/config/regional/settings

and setting the Default Time Zone to UTC (right at the bottom of the list) - fixed everything for me.

Might be worth a try.

I had a similar problem, but this didn't solve it for me because, while my Drupal site was set to the proper time zone, the site regional config allowed "Users may set their own time zone.". The problem for me was that I, the logged-in admin user, had my time zone inadvertently set to UTC. So CiviCRM was reading my Drupal user time when, for example; creating bulk mailings. I would create a mailing an 12:00 (my actual local time, and server time), yet the "Draft/Scheduled Mailings" in CiviCRM showed it was created at 5:00PM/17:00! This was because my Drupal user profile was indeed set to UTC.

The lesson being - if all of your server tzdata, localtime, PHP, and MySQL settings are correct, and you're still having problems - be sure your Drupal user timezone is also set properly.  Hope this helps someone else, this one was quite a pain for me to finally track down.

--Tony


Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Internationalization and Localization (Moderators: Michał Mach, mathieu) »
  • <solved>Timestamps reported by MySQL and PHP are mismatched

This forum was archived on 2017-11-26.