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 »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Timezone question
Pages: [1]

Author Topic: Timezone question  (Read 1982 times)

adixon

  • I post frequently
  • ***
  • Posts: 314
  • Karma: 19
    • Blackfly Solutions
Timezone question
July 07, 2011, 12:16:09 pm
Using, drupal 6/civicrm 3.3.6, when I get a registration confirmation, the Registration Date shows up in GMT, but doesn't qualify itself in the display (i.e., so everyone thinks it's actually wrong ...)

It makes sense to store it in GMT in the database time fields, for portability/flexibility ..., and it appears to be going through the crmDate smarty plugin before display, so in order to specify a different timezone for the civicrm installation, would it not be possible to hook in at that point?

It seems there's been discussion about some kind of timezone configuration, but even just using php's default timezone would be nice. Or a custom variable in the config file, would be dandy ... I'm happy to offer a patch if this sounds like the right approach.

adixon

  • I post frequently
  • ***
  • Posts: 314
  • Karma: 19
    • Blackfly Solutions
Re: Timezone question
July 18, 2011, 01:19:55 pm
Any input here? I'm finding it hard to believe that no one else has this issue ... if you think it's something wrong with my installation, please tell me.

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 question
July 18, 2011, 01:26:16 pm

hey alan:

we use the standard php time zone. note that in php 5.3 u might need to specify it in your php.ini just to make it more explicit

in some cases, when my server and user base have been on different time zones, i've set it in the config hook, check:

http://svn.civicrm.org/sfschool/branches/v3.2/drupal/sfschool/sfschool.module

search for date_default_timezone_set

we store all date/time in mysql format (which is basiclly YYYY-MM-DD (maybe based on locale?)) in the timezone as specified by the install

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

adixon

  • I post frequently
  • ***
  • Posts: 314
  • Karma: 19
    • Blackfly Solutions
Re: Timezone question
July 18, 2011, 02:12:20 pm
Thanks, but I think one or both of us is still confused.

In reading other posts about timezones, and looking at what's stored in the database for events, it appeared to me that the dates for events, anyway, are always converted to GMT before being stored in the database, and that seems like a reasonable strategy.

But your comment suggests this is only happening in my install because I haven't set the php timezone, yet I'm pretty sure I have: I've put this into my drupal settings.php file:

Code: [Select]
ini_set('date.timezone','America/Toronto');

As an interim solution i've just added this into the top of the customFormat function in CRM/Utils/Date.php, which converts it to drupal's date_default_timezone on output:

Code: [Select]
  static function customFormat($dateString, $format = null, $dateParts = null)
    {
        if (function_exists('variable_get')) {
          $timezone = variable_get('date_default_timezone', 0);
          if ($timezone) {
            $ts = strtotime($dateString) + $timezone;
            $dateString = date('Y-m-d H:i:s',$ts);
          }
        }

But i suspect I'm going to be converting some dates that do have date/time stored in toronto time ...

adixon

  • I post frequently
  • ***
  • Posts: 314
  • Karma: 19
    • Blackfly Solutions
Re: Timezone question
July 18, 2011, 02:13:00 pm
Also - in case this matters - I'm still using php 5.2

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Timezone question
July 18, 2011, 04:18:57 pm
Alan - I'm not a timezone expert (at all) - caveat. But ... I just ran a test on my localhost install (running PHP 5.3.6 on Mac Snow Leopard). My php.ini has these settings:

date/time support => enabled
"Olson" Timezone Database Version => 2011.4
Timezone Database => internal
Default timezone => America/Los_Angeles

I just used "Register Participant" for to register someone for an event (at 4:09pm PDT). The Participant View screen shows July 18th, 2011 4:09 PM  for Registration Date and Time. My DB has this value in Register_Date column: 2011-07-18 16:09:00

So at least in my environment the date is being stored in my local timezone. For what it's worth.
Protect your investment in CiviCRM by  becoming a Member!

adixon

  • I post frequently
  • ***
  • Posts: 314
  • Karma: 19
    • Blackfly Solutions
Re: Timezone question
July 19, 2011, 04:46:10 am
Thanks, sounds like it's my install, i'll go back and try some more.

adixon

  • I post frequently
  • ***
  • Posts: 314
  • Karma: 19
    • Blackfly Solutions
Re: Timezone question
July 21, 2011, 02:37:49 pm
Okay, so neither of us is completely bonkers, but there is an issue here.

The key tool for debugging this was the drupal -> reports -> status report -> php page that runs php.info - it showed me that regardless of my settings in php.ini, or settings.php, the timezone was being forced to UTC.

I did a grep on my modules and discovered that the drupal date api module is doing this - it's forcing php's timzone to be UTC.

As it turns out, I only needed this because of a dependency with node import, which I no longer need, so I can solve my immediate problem as you recommend (e.g. in the settings.php - i've no also set it in my server's php.ini file).

But for many sites - i.e. any that also use drupal's date module, this could be a pretty big problem.

If anyone has this issue and needs a quick solution - my little hack above is a sort of solution - allowing the database to store dates UTC and to convert to the default drupal timezone on output of all dates.

Actually, since most of my civicrm sites do use drupal's date module, I'm tempted to use this as my default solution. To make it a solution that would work more widely, we'd need:

1. A civicrm policy decision to always store dates as UTC.
2. A way of identifying the site's default timezone when using joomla.
3. Some kind of initialization/configuration code that grabs the site's default timezone from the CMS or a reasonable default and stores it in a global.
4. An appropriate update to my little script above.

zbgc

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
  • CiviCRM version: 3.4.5
  • CMS version: Drupal 6.22
  • MySQL version: 5.0.91
  • PHP version: 5.2.17
Re: Timezone question
July 24, 2011, 09:38:28 pm
I'd like to request that, if possible, any changes made to CiviCRM on this issue take into consideration the note I left at forum.civicrm.org/index.php/topic,20707.0.html - it would be great to be able to configure CiviCRM such that its iCalendar output could work around Google Calendar's timezone-handling issues. :-)

Thanks!


Alexis.
« Last Edit: July 25, 2011, 01:41:34 am by zbgc »

adixon

  • I post frequently
  • ***
  • Posts: 314
  • Karma: 19
    • Blackfly Solutions
Re: Timezone question
May 04, 2012, 01:15:05 pm
I see the whole topic of timezones is kind of confusing and confused.

To add to my confusion, I'll note that since I posted this, i've had to revert this customization because the default timezone started getting set properly. I assume this is related to my php 5.2 to php 5.3 update.

Conclusion: you probably need to look at your version of php if reporting/requesting any timezone issues.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Timezone question

This forum was archived on 2017-11-26.