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) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • WordPress Time Zone Problem
Pages: [1] 2

Author Topic: WordPress Time Zone Problem  (Read 35329 times)

aglozier

  • I post frequently
  • ***
  • Posts: 135
  • Karma: 9
    • Phoenix Academy
  • CiviCRM version: 4.7.9
  • CMS version: WordPress 4.6.1
  • MySQL version: 5.7.14
  • PHP version: 5.6.21
WordPress Time Zone Problem
August 10, 2012, 03:43:10 pm
I'm having problems with CiviCRM displaying GMT in various places.  Some of these are:
  • Data Entry - Time defaults to GMT.
  • Change Log - Time is GMT
  • Scheduled Jobs - Last run time is GMT.  However, logs show local time.

This happens on both our production server (HostGator) and test server.  The test server is a computer in my home on which I installed the TurnKey Linux WordPress Appliance and CiviCRM.

I've searched this forum and found that several others have had this problem.  However, none are running WordPress.  I've done all my trouble shooting so far on the test server.  Based on the posts I read, I've done the following:
  • Checked and corrected my system and hardware times.
  • Set the time zone in both PHP.ini files (Apache and CLI).
  • Tried setting the timezone in the civicrm settings file. i.e. ini_set('date.timezone','America/Chicago');
None of the above worked.  I checked the local time in PHP CLI using this command: php -r 'echo date(DATE_RSS);'.  I get the correct time.

Does anyone have any suggestions?  Is this an issue with the WordPress version?

George
« Last Edit: August 11, 2012, 08:42:26 am by aglozier »

aglozier

  • I post frequently
  • ***
  • Posts: 135
  • Karma: 9
    • Phoenix Academy
  • CiviCRM version: 4.7.9
  • CMS version: WordPress 4.6.1
  • MySQL version: 5.7.14
  • PHP version: 5.6.21
Re: WordPress Time Zone Problem
August 11, 2012, 07:46:39 am
I have an update.  I figured out how to embed PHP code in a WordPress post.  I embed "echo date(DATE_RSS)" in a test post.  It displays GMT.  So the problem is not CiviCRM.

Any ideas on how to trouble shoot this?

For those interested, I installed the "Allow PHP in posts and pages" WordPress plugin.  Here's what I put in the test post:

<phpcode>
<?php echo date(DATE_RSS); ?>
</phpcode>


« Last Edit: August 11, 2012, 08:41:45 am by aglozier »

aglozier

  • I post frequently
  • ***
  • Posts: 135
  • Karma: 9
    • Phoenix Academy
  • CiviCRM version: 4.7.9
  • CMS version: WordPress 4.6.1
  • MySQL version: 5.7.14
  • PHP version: 5.6.21
Re: WordPress Time Zone Problem
August 11, 2012, 08:40:36 am
I found the problem.  Once I realized it wasn't a CiviCRM problem, I searched for WordPress PHP time zone problems.  I found it here:

http://name1price.com/how-to-get-customers-with-singapore-web-design-basic/wordpress-tutorials/128-setting-the-default-timezone-in-wordpress.html

Line 32 in the wp-settings.php file sets the time zone to UTC (i.e GMT).  You have to change it to your time zone.

I applied the fix and it corrected the problems I listed in my original post.

SandraC

  • I post occasionally
  • **
  • Posts: 32
  • Karma: 0
  • CiviCRM version: 4.4.5
  • CMS version: WordPress 4.0
  • MySQL version: 5.5.30
  • PHP version: 5.3.20
Re: WordPress Time Zone Problem
May 22, 2013, 11:42:31 am
Has anyone else tried this with success? If I muck around this php file has it broken anything CiviCRM? I guess my question: is this Civi-approved or is that a non-issue? Thank you!
<3

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: WordPress Time Zone Problem
May 22, 2013, 11:46:18 am

this seems like a lot better fix:

http://issues.civicrm.org/jira/browse/CRM-12523

This fix is part of 4.3.3

no need to hack WP core (or Civi core)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

aglozier

  • I post frequently
  • ***
  • Posts: 135
  • Karma: 9
    • Phoenix Academy
  • CiviCRM version: 4.7.9
  • CMS version: WordPress 4.6.1
  • MySQL version: 5.7.14
  • PHP version: 5.6.21
Re: WordPress Time Zone Problem
May 23, 2013, 12:15:06 pm
I'm not sure the fix in 4.3.3 fixed all the time zone issues.  In particular when you enter a new contribution the 'Time Received' defaults to UTC not local time.  The mod to " wp-settings.php' makes the default local time.  This was one one reason I originally investigated this.  The other was the CRON run times which I didn't check to see if 4.3.3 fixed.

I tested this by upgraded a vanilla 4.3.1 test installation I have to 4.3.3 and then selecting add new contribution.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: WordPress Time Zone Problem
May 23, 2013, 04:01:06 pm

I did a quick simple test locally (i had set my TZ in WP to be pacific) and it seemed to work fine for the new contribution page in the latest 4.3.x

in general, we dont recommend hacking either civi or wp. so would be good to try and fix this in most/all places. So would be great if you can track down whats happening and why and submit a patch once u find the bug

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

aglozier

  • I post frequently
  • ***
  • Posts: 135
  • Karma: 9
    • Phoenix Academy
  • CiviCRM version: 4.7.9
  • CMS version: WordPress 4.6.1
  • MySQL version: 5.7.14
  • PHP version: 5.6.21
Re: WordPress Time Zone Problem
May 23, 2013, 04:28:52 pm
I agree that you don't want to hack the code and that it would be best for CiviCRM to set the time.  But in this case I believe the WordPress code is designed to let you set the time zone.  Here is the code:
Code: [Select]
// Set default timezone in PHP 5.
if ( function_exists( 'date_default_timezone_set' ) )
date_default_timezone_set( 'America/Chicago' );
Normally it reads UTC.

Until I can figure this out, I'll have to hardcode the time zone.

SandraC

  • I post occasionally
  • **
  • Posts: 32
  • Karma: 0
  • CiviCRM version: 4.4.5
  • CMS version: WordPress 4.0
  • MySQL version: 5.5.30
  • PHP version: 5.3.20
Re: WordPress Time Zone Problem
May 27, 2013, 03:32:13 pm
Thanks for all the responses. Since we are still in development, we will move forward with the upgrade and see what that "fixes". The go to the WP php file after that...
<3

SandraC

  • I post occasionally
  • **
  • Posts: 32
  • Karma: 0
  • CiviCRM version: 4.4.5
  • CMS version: WordPress 4.0
  • MySQL version: 5.5.30
  • PHP version: 5.3.20
Re: WordPress Time Zone Problem
June 07, 2013, 07:30:25 am
Update: We did upgrade to 4.3.3 and the Time Zone did not adjust correctly. I did have to go into the wp-settings.php file and set the default time zone to 'New York', and also changed it in settings in Wordpress dashboard. Date is now showing correctly in CiviCRM. (For example, when adding a contribution for an individual contact, the time did show the correct time.)

Thank you to all who share in this forum, I find it very helpful as a beginner! Peace!  ;D
<3

Dennis Gray

  • Ask me questions
  • ****
  • Posts: 472
  • Karma: 1
  • CiviCRM version: Various. See post.
  • CMS version: Drupal, Wordpress and Joomla. See post.
  • MySQL version: TBA
  • PHP version: TBA
Re: WordPress Time Zone Problem
July 06, 2013, 07:50:19 pm
CiviCRM 4.3.4 installed
WP  3.5.1

I solved my problem

In the dashboard, I set the time to local time ICT.
In wp-config.php I set default time zone to ICT.
It is my server (Rackspace) so I set the tzdata with dpkg-reconfigure tzdata to ICT

Emails now go out immediately.

rd11

  • I’m new here
  • *
  • Posts: 18
  • Karma: 1
  • CiviCRM version: 4.5
  • CMS version: Wordpress
  • MySQL version: 5.5 (Amazon RDS)
  • PHP version: 5.3
Re: WordPress Time Zone Problem
July 12, 2013, 09:51:08 am
I'm not sure the patch fixed all of the timezone issues either. Particularly: scheduled jobs (*when executed through the cron.php URL method*) still show UTC time even though other dates reflect the proper timezone.

Going to put the workaround hack in the config files until it's fixed.

aglozier

  • I post frequently
  • ***
  • Posts: 135
  • Karma: 9
    • Phoenix Academy
  • CiviCRM version: 4.7.9
  • CMS version: WordPress 4.6.1
  • MySQL version: 5.7.14
  • PHP version: 5.6.21
Re: WordPress Time Zone Problem
July 12, 2013, 02:31:16 pm
I noticed that with the CRON back when I first investigated this and found the hack.

viusdeveloper

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
    • VIUS, LLC - Philadelphia Web Design & Development
  • CiviCRM version: 4.3.5
  • CMS version: Wordpress 3.5.2
  • MySQL version: 5.x
  • PHP version: 5.3.x
Re: WordPress Time Zone Problem
July 25, 2013, 07:19:33 am
I'd like to reiterate that on CiviCRM 4.3.5 this is still broken on the cron.php execution path.
I've noticed that when running scheduled jobs manually, they correctly adjust their timezone (likely because CiviCRM is running inside the Wordpress "context".

However, when running a cron job against /bin/cron.php directly, the timezone offsets are different. This is causing Jobs scheduled to run at say 8AM EST to actually run at 8AM GMT when cron triggers them, but to run at 8AM EST when run manually via /wp-admin/.

Since the cron.php file is being called directly, and not as part of Wordpress, it seems a better solution to this would be if CiviCRM tied the cron.php execution into the existing wp-cron.php functionality that's used on Wordpress sites. At the moment, it doesn't appear to be using that as setting a cron job up for wp-cron.php doesn't cause the CiviCRM scheduled jobs to run.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: WordPress Time Zone Problem
July 25, 2013, 10:07:12 am

i dont know if wp-cron.php is extensible, if so might be good to write a small plugin to hook civi's cron.php to wp's wp-cron.php

civi needs to handle the tz setting from the CMS in a better manner. right now it just uses the default setting from php

lobo

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • WordPress Time Zone Problem

This forum was archived on 2017-11-26.