I created a new content type with a date field. Then I create a node using this content type and fill in the date. The new node displays the date as 4 hours later than the time I specified. And if I edit the node, the later time plus one hour is entered for me in the time pulldowns. Clicking Submit adds another 4 hours to this.

This happens using defaults for the date field setup: Select List, no time zone conversion. Also happens with many combinations of site and the date field timezone settings (tried No Conversion, and also used UTC for both the site and the date field). Happens with a selector, jscalendar, and text input. Date or datestamp. Basically, every permutation I tried, it still happens. Even on a fresh 5.7 install with only CCK and Date modules enabled.

Drupal 5.7, PHP 4.4.7 and Date PHP4 module enabled (no problem when using PHP 5.2.5 instead of the Date PHP4 module).

Let me know what I can do to help isolate the problem.

Comments

alpinejag’s picture

I'm having the same problem. Fairly fresh install of Drupal 5.7 and I'm using Date 5.x-1.8. Server is PHP 5.2, Zend Optimizer 3.2.2. It's also happening when I'm using Node Import to import dates.

slindhurst’s picture

Title: 4 hours added to time when preview or submit » date_make_date() adds one hour during (US) DST, even in UTC

I managed to narrow down the problem somewhat. At least I hope I have, despite my non-existent PHP skills. date_make_date(...,'UTC', DATE_ISO) adds one hour during daylight saving time. For example, on the first day of DST this year:

  $date = date_make_date('2008-03-09T10:24:00', 'UTC', DATE_ISO);
  print_r ($date);

outputs one hour later: stdClass Object ( [value] => 2008-03-09 11:24:00 [timestamp] => 1205065440 [timezone] => UTC )

Doing the same thing for a date during standard time returns the same date as input:

  $date = date_make_date('2008-03-08T10:24:00', 'UTC', DATE_ISO);
  print_r ($date);

stdClass Object ( [value] => 2008-03-08 10:24:00 [timestamp] => 1204971840 [timezone] => UTC )

Just in case I'm misunderstanding the date_make_time API (a distinct possibility), here's a roundtrip example (similar to one in the Date API unit test) that I'm more confident should return the input date:

  $unix = date_convert('2008-03-09T10:24:00', DATE_DATETIME, DATE_UNIX);
  $datetime = date_convert($unix, DATE_UNIX, DATE_DATETIME);
  print_r ($unix); print '<br>'; print ($datetime);
1205061840
2008-03-09 12:24:00 

The Unix date looks correct to me (3600 seconds earlier than the 2008-03-09 11:24 printed above), but the datetime is 2 hours later than the input time.

The above examples were all created with the site set to UTC (and a fresh Drupal 5.7 install, PHP 4.4.7 on my local machine using MAMP). I also observed the same behavior on a old test site still on Drupal 5.2, PHP 4.4.8, and US/Pacific.

stborchert’s picture

Hi.
I noticed the same problem on our site. If I set the value of my cck date field to "2008-04-15 04:00" it is displayed as "2008-04-15 06:00" (Timezone is "Europe/Berlin", changing this has no effect). Editing the node the time is displayed as "2008-04-15 08:00" (adding 2 hours again).

PHP Version 4.4.7; Apache/1.3.31

greetings,

Stefan

seanr’s picture

Priority: Normal » Critical

Similar problems here. I basically can't get event times to display correctly at all right now, no matter what I try.

macgirvin’s picture

Subscribing. I'll be poking into this deeper. I notice several of you are using PHP4.x, which may be important in solving this. The Date module has different behavior depending on your PHP version and setting the option to use the Date compatibility layer with PHP4 (actually any PHP < 5.2). It would be most helpful if you could supply your PHP version and the status of the compatibility setting for the purposes of this issue. Most of these reports are PHP4. The report from PHP5.2 seems a bit odd in this context, but I don't know if the compatibility flag was turned on.

slindhurst’s picture

By "compatibility setting", do you mean whether the "Date PHP4" module is enabled? If so, yes, I have that enabled when using PHP 4.4.7 (using date_convert under PHP 4 without the Date PHP4 module gives a WSOD, not surprisingly). When testing on PHP 5.2, I see no problems whether or not Date PHP4 is enabled (maybe the PHP4 compatibility layer isn't used at all under PHP 5.2?).

My simple test: paste my date_convert snippet in #2 on a new page with PHP input format, then hit Preview.

edg’s picture

subscribing

macgirvin’s picture

Apologies, it seems I no longer have a stable PHP4 available - I'm going to have to let somebody else track this one down.

karens’s picture

I made a number of commits yesterday and it's possible some of them could have some impact on this issue. There should definitely be no problem in PHP 5. I am not set up right now to test PHP4, so I'd appreciate someone using PHP4 testing the very latest -dev version of the Date module to see if this is still a problem there.

karens’s picture

Status: Active » Fixed

After doing more research I found that there was a problem using PHP 4 where I tried to limit the need for the more complex code by using strtotime and mktime for current dates instead of the more complex functions. When I change the code to use the complex functions in all cases, I can make a proper round trip of a date to a unix timestamp and back, so I've change the code to do that always. I'm not sure this takes care of every place there might be a problem in PHP 4, but hopefully it will fix most situations.

slindhurst’s picture

This fixes all of the date API and date field problems I've seen: dates during DST and outside DST both work correctly, either using Date API directly or using a date as a CCK field. Thanks!

But I did some testing with Calendar 5.x-2.x-dev (dated 23-April), and found a problem. Dates displayed on the calendar are displayed with some timezone offset subtracted in certain cases. When my site timezone is set to US/Pacific, a 10:00 event is displayed as 02:00 on the calendar. Changing the site timezone to US/Eastern changes the display to 06:00. Strangely, changing the site timezone to Etc/GMT-8 keeps the calendar event displayed correctly, at 10:00. (These are all for a CCK date field not using any timezone conversion.)

I'll have to test some more to see if this is a bad setting on my part somewhere. If not, I can open a new issue to make it easier to track. (All this happens with PHP 4; I've been unable to test against PHP 5.2 this morning for some reason).

Edit: I saw another issue somewhere about the calendar problem, saying the calendar module needed updating for changes in Date. So I'm not worrying about it.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.