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 »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Timezone issue -- CiviCRM is using UTC instead of the webserver/PHP time
Pages: [1]

Author Topic: Timezone issue -- CiviCRM is using UTC instead of the webserver/PHP time  (Read 1457 times)

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
Timezone issue -- CiviCRM is using UTC instead of the webserver/PHP time
April 21, 2013, 09:08:45 am
I am using CiviCRM on Wordpress. I can run a test snippet in a file at the site root,

Code: [Select]
<?php echo date('Y-m-d g:i:s a'); ?>
and get the correct time (i.e. the web server time, ET). However, CiviCRM is using GMT/UTC. For example, whenever I edit a contact, the "last change" time reflects the time in UTC.

Everything I have read on the forums indicates that CiviCRM uses the web server time from PHP. It doesn't seem to be doing that?

For what it's worth, the time zone configured in Wordpress is Central Time.

Any ideas?

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: Timezone issue -- CiviCRM is using UTC instead of the webserver/PHP time
April 21, 2013, 09:49:57 am

can you try that statement within the civicrm code base (maybe in civicrm/civicrm.php, civicrm_wp_invoke?) and see what the timezone is in there

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

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: Timezone issue -- CiviCRM is using UTC instead of the webserver/PHP time
April 21, 2013, 10:06:00 am
When I run it from the CRM codebase, it has the UTC time.

Could Wordpress be doing something to the time before CiviCRM pulls it?

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: Timezone issue -- CiviCRM is using UTC instead of the webserver/PHP time
April 21, 2013, 11:00:58 am
seems like WP is setting the timezone to UTC

i did a quick check and then a grep in the codebase

in wp-settings.php

// WordPress calculates offsets from UTC.                                                                                                                                 
date_default_timezone_set( 'UTC' );

also check:

http://wordpress.stackexchange.com/questions/30946/default-timezone-hardcoded-as-utc

so really sucky that WP does this, not sure what/how/where we'll even handle this

lobo
« Last Edit: April 21, 2013, 11:03:00 am by Donald 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

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: Timezone issue -- CiviCRM is using UTC instead of the webserver/PHP time
April 21, 2013, 11:22:01 am
I've temporarily fixed the issue by changing the timezone in WP-settings.

Not really sure what repercussions this will have on non-CRM date/time operations but will check in if anything is amiss.

In any event, it's not an ideal solution as wp-settings will need to be changed with each new Wordpress version.

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: Timezone issue -- CiviCRM is using UTC instead of the webserver/PHP time
May 11, 2013, 06:25:25 am
I previously posted about this here: http://forum.civicrm.org/index.php?topic=25625.0.  I described how you can fix this by editing a line in the wp-settings.php file.  This has to be repeated every time you upgrade WordPress.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Timezone issue -- CiviCRM is using UTC instead of the webserver/PHP time

This forum was archived on 2017-11-26.