CCK/date field/views/timezones - I'm close to shooting myself

muszek - January 15, 2007 - 16:34

hi.

We're creating a news site about our city (krakownews.pl) and are using Drupal 5 (RC 1

at the moment). One of the more imporant features of this site is an overview of cultural/sports events that are about to

happen. I used CCK to create a "wydarzenia" ("events" in Polish) content type which, among other things (like ticket price,

for example) has a date field. Then I used views module to create a page that lists todays events and several blocks (like

"upcoming important events", "tomorrow...", etc.). I simply created a "date: day = now" (for today) and "date: day = now -

86400" (why minus works, not plus, is beyond me).

Everything works very nice... except the way time is handled. Views/CCK/Drupal core (it's not always clear which one) give

us irritating bugs all the time. I don't even know where to start, so I'll just list several things that I noticed.
* if I set up CCK's date field to "no time zone conversion", date is being "pulled back" one day in a form every time I load

a "edit node" page. Example: I create an even titled "massive attack concert" with a date 15.01.2007. I save it, click on

edit and there's 14.01.2007 in an edit form. Also, if I use this setting, views show select incorrect nodes after midnight

(haven't stayed up that long, but something tells me that it's wrong until 7 a.m. - difference between site's timezone and

server's timezone).
* if I set up CCK's date field to "site's timezone", edit works properly, but views don't, depending on when I save current

view... if I save a view when CCK's field was set to "site's timezone", views work wrong. It's so complicated I'm not sure

how to describe it.

Here's what I did the last: I edited CCK's date field and set it to "site's timezone". Then I edited all existing nodes

(just edit->save) to convert their date field to the new setting. It worked fine (it was around 2a.m.). Then I edited a

view (something formatting-related) and it got screwed up (showing pre-midning nodes, instead of current day ones). I

figured out that CCK's date field was the only thing that I changed in the mean time. So I changed it back to "no timezone

conversion" for a moment, then did edit->save view and then changed CCK's date field again to "site's timezone". It worked

properly... until the morning. Now there are tomorrow's nodes on "today's events" page.

As you can see, I really need your help. If you have a friend who's a shrink, that would be great at this stage, too.

All I need is to give a "date" property (separate from node's creation date, of course) to a node and show a list of nodes that have today's date (or tomorrows in a block). Please help us...

Background info: site's timezone is CET (Central Europe, GMT +1). Server's time (it's on Debian) is CST (Central Standard

Time, GMT -6).

sorry for the formatting...

muszek - January 15, 2007 - 16:37

sorry for the formatting... I'm using someone else's computer and I'm a bit lost with MS Notepad. Apparently I can't edit my own post :/. Here's the text again:

hi.

We're creating a news site about our city (krakownews.pl) and are using Drupal 5 (RC 1 at the moment). One of the more imporant features of this site is an overview of cultural/sports events that are about to happen. I used CCK to create a "wydarzenia" ("events" in Polish) content type which, among other things (like ticket price, for example) has a date field. Then I used views module to create a page that lists todays events and several blocks (like "upcoming important events", "tomorrow...", etc.). I simply created a "date: day = now" (for today) and "date: day = now -86400" (why minus works, not plus, is beyond me).

Everything works very nice... except the way time is handled. Views/CCK/Drupal core (it's not always clear which one) give us irritating bugs all the time. I don't even know where to start, so I'll just list several things that I noticed.
* if I set up CCK's date field to "no time zone conversion", date is being "pulled back" one day in a form every time I load a "edit node" page. Example: I create an even titled "massive attack concert" with a date 15.01.2007. I save it, click on edit and there's 14.01.2007 in an edit form. Also, if I use this setting, views show select incorrect nodes after midnight (haven't stayed up that long, but something tells me that it's wrong until 7 a.m. - difference between site's timezone and server's timezone).
* if I set up CCK's date field to "site's timezone", edit works properly, but views don't, depending on when I save current view... if I save a view when CCK's field was set to "site's timezone", views work wrong. It's so complicated I'm not sure how to describe it.

Here's what I did the last: I edited CCK's date field and set it to "site's timezone". Then I edited all existing nodes (just edit->save) to convert their date field to the new setting. It worked fine (it was around 2a.m.). Then I edited a view (something formatting-related) and it got screwed up (showing pre-midning nodes, instead of current day ones). I figured out that CCK's date field was the only thing that I changed in the mean time. So I changed it back to "no timezone conversion" for a moment, then did edit->save view and then changed CCK's date field again to "site's timezone". It worked properly... until the morning. Now there are tomorrow's nodes on "today's events" page.

As you can see, I really need your help. If you have a friend who's a shrink, that would be great at this stage, too.

All I need is to give a "date" property (separate from node's creation date, of course) to a node and show a list of nodes that have today's date (or tomorrows in a block). Please help us...

Background info: site's timezone is CET (Central Europe, GMT +1). Server's time (it's on Debian) is CST (Central Standard Time, GMT -6).

I would suggest going to the

KarenS - January 15, 2007 - 18:21

I would suggest going to the date module (http://drupal.org/project/date) to report this on the date issues queue so it can be followed up on properly. You'll need to provide some additional info to be able to debug this (report it on the issue queue):

1) Install the content_copy module that comes with CCK and export the content type that you're having trouble with and post it in your issue so I can see how you have set up your fields.

2) Export all the involved views and post them in the issue so I can see how you have set up your views.

3) Provide some info on how and where you set up the blocks that aren't working. Neither CCK nor the date module creates any blocks so they're coming from somewhere else.

4) Provide list of any other date-related modules you are using, if any (Event, Calendar, etc).

Plus update to the latest versions of everything and see how that affects your problems. There is a shiny new version of Drupal and many recent change to all these modules.

Anyway, as I said, please post all that info on the Date module issue queue, not here, because the forums are not set up right for tracking and debugging things like this.

Exact same problem! Did this

Prodigy - August 4, 2007 - 02:58

Exact same problem! Did this get fixed??

Similar problem

GN - August 7, 2007 - 20:29

Similar problem for me: events are incorrectly grouped by months. If I don't enter event time, i.e. it the start date is e.g. June 1, and the time by default is 00:00, the event is shown as starting in May instead of June (and other June events are also shown as belonging to May, though the month number in the group URL is correct). I had to add hour granularity (though I don't need it) and specify time e.g. 9am instead of 0, and then it works correctly. It looks like there is some strange time zone correction (though it should be turned off). I see http://drupal.org/node/165042 - "This is an issue in the Views integration portion of the Date module".

PHP version matters

GN - August 8, 2007 - 08:13

Also, it seems to depend on the PHP version -- I tried to check it on a localhost server with PHP 5.2.3, and the dates worked fine, while it was buggy on a hosting server with PHP4. (I think KarenS, the date module developer, has already mentioned some PHP version-dependent issues -- http://drupal.org/node/147392).

If you find a fix, any other

Prodigy - August 8, 2007 - 13:15

If you find a fix, any other way than using hours/minutes please let me know.

The problem can't be that hard to fix, it's just a matter of finding where the problem is at. I've got the summary done in a custom block using PHP, but I would really like to use the Views summary instead.

A wild guess

GN - August 8, 2007 - 19:56

A quick-n-dirty solution that occurs to me is to try modifying the date module code in such a way that without using hrs/mins granularity the hour value is by default set to 12 instead of 0 -- I guess in this case a time zone offset incorrectly applied to the hour would be less likely to change the date.

Now - 6 hours = Now CST

WisTex - February 5, 2008 - 12:25

How do you get a view to show Now minus 6 hours? The server is in GMT, and we are GMT -6, so basically 6 hours of the day, the calendar is wrong (shows tomorrow instead of today) and any views that are supposed to show today's items do not show anything less than 6 hours from now. Basically the whole system is 6 hours off, despite setting Drupal's default timezone to CST (GMT-6) and setting my logged in user's timezone to CST (GMT-6) also. Calendar and views completely ignores any time zone settings made in Drupal.

In Views, I know you can specify "now" for a date range which will give you GMT Now. How do you get Now GMT-6? Or Now minus 6 hours. Or even Now minus 1 day. That would even work.

I can't seem to find the documentation telling you how to properly format such requests in a Views date range field.

Example view where "Filter: Greater than or equal to Now" is used:
http://www.wistex.biz/upcoming

This needs to be "Filter: Greater than or equal to Now - 6 hours" to show all of today's events, due to the time zone difference.

Thanks.

--
Scott M. Stolz
http://www.wistex.com/

 
 

Drupal is a registered trademark of Dries Buytaert.