The event calendar somehow picks up what the current day is and uses it to display todays events by default and to style today differently with CSS. The "current day" shown on my calendar is always a day ahead of what it really is supposed to be. To be more exact around late afternoon the day switches to the next day.

I've checked the time my server is set to and it is correct for the region it resides in, I have also checked the Drupal system time and it is correct, and I even have the Event Module set to use the sitewide time zone.

Anyone know what could be causing this?

CommentFileSizeAuthor
#3 event_date_patch_0.txt404 bytesVanhail

Comments

macgirvin’s picture

subscribe

jody lynn’s picture

Check your site's timezone setting. If you have not set your site's timezone setting but your server (out of your control) has a timezone setting, then the day will change at the wrong time. Either set your site's timezone or change this function in event.module to the following so it ignores your server's timezone (remove the date("Z") stuff):

 function _event_user_time() {
  global $user;

  if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
    return (time()) + $user->timezone;
  }
  else {
    return (time()) + variable_get('date_default_timezone', 0);
  }
}
Vanhail’s picture

StatusFileSize
new404 bytes

This is a bug in the event module for version: 5.x-1.0. I assume it's been around for earlier versions. Pretty big bug in my opinion, dates need to be correct for an event module to be valid.
I have attached the patch, I just manually added the code and it worked for me. This thing drove me nuts.

BTW, I've seen this in multiple threads with no answer, so I'm posting this message in all of them. Blasted bug.

gthing’s picture

I applied the patch (actually I edited the code manually), but it made no change. My calendar still shows the wrong day.

If I go to administer date and time, the little previews show the wrong information as well. I checked my server and it is set to the correct date. So the question is where is the date being pulled from? Where can I set it?

Thanks.

jonny_noog’s picture

Hello,

I have tried the solutions outlined in the above posts from Vanhail and Lynn and both seem to work for me... Kind of.

My timezone is GMT + 10 hours. Checked the server time, and the site wide Drupal time, both are correct.

Before applying either of these proposed patches, my event calendar was showing yesterday as the current day, highlighted in red.

If I apply either of these patches, it seems to start highlighting today as the current day in red, BUT still highlights yesterday in blue (when looking at the month view).

Can anyone comment on why it's highlighting yesterday in blue, and how I could stop this from happening?

I see that it is adding a 'selected' CSS class to yesterday, which I assume is the CSS class that makes yesterdays box blue... I guess I could always just mess with this style, or stop it from being applied somehow, but I don't know if this is a good solution... What does this 'selected' style usually signify?

Also, this is probably a really n00b question, but I see people posting "subscribe" in this thread... Is there some way to subscribe to this thread? Is that what this means?

Any assistance much appreciated.

EDIT: Found the subscribe feature... yay.

GoofyX’s picture

Component: Basic Event » Code

Subscribing...

gerhard killesreiter’s picture

I suggest to try the 5.x-2.x-dev version. Don't forget to backup your data.

johnhorning’s picture

Thanks Vanhail! - worked for me.

johnhorning’s picture

...

jasonsbytes’s picture

I went with Lynn's suggestion and that worked for me.

What I found was for this line:
return (time() - date("Z")) + variable_get('date_default_timezone', 0);

time() -- returns seconds since epoch
date("Z") -- returns -18000 for me or -5 hours for US Central time
variable_get('date_default_timezone', 0) -- returns -18000 also.

So essentially it is subtracting -18000 (same as adding 18000) to time(), then it adds -18000 (same as subtracting it), so what I end up with is the original value of time() anyways, which is UTC time not counting for my TZ offset.

I'm not sure if this is an issue with the math or TZ settings or just bad logic...

Any thoughts? Either way, removing the date("Z") returns the correct value, so thanks Lynn.

I am now using this line:
return (time() + variable_get('date_default_timezone', 0));

dean.p’s picture

Thanks jasonsbytes, that worked for me :)

Even though my server was set to the right timezone, user TS, and even enabling/disabling configurable timezones didn't fix it... calendar was always showing the current day 1 day behind.

Sack

gthing’s picture

Turns out my calendar had user definable time zones enabled. This was causing all sorts of wonkyness. I took that settings off and then was able to set the system time correctly.

gthing’s picture

Is active development taking place on the events module? It seems very buggy - I've never gotten it working properly and now if I so much as enable the events module my whole site goes down. I've dumped the tables (the module had mangled all of the dates on every event anyway) and I still can't even get it to enable.

I've lost a year's worth of events on a production site now and have no way of getting things working again...

banjer’s picture

I did something similar, so if jasonsbytes' didn't work for you then try this. Its a little more work. My problem was that everyday at 9pm, the event calendar display would go to the next day. So this meant the event system thought my time was +3 hours ahead of what it actually was. So what I did was:

1. looked in event_timezones.inc (function event_get_timezones) for a timezone that is 3 hours ahead of mine (I'm on the east coast, so I chose Los Angeles). The offset for LA is -28800.

2. used the -28800 offset in the code change below in event.module:

function _event_user_time() {
  global $user;

  if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
    return (time() - date("Z")) + $user->timezone; // i don't allow users to configure timezones, so I didn't change this piece
  }
  else {
    //return (time() - date("Z")) + variable_get('date_default_timezone', 0); // original code
    return (time() - date("Z")) - 28800; // my hardcoded timezone offset
  }
}

Everything works great now. Someone proposed a similar idea in another issue, but I can't find it or else I'd link it here. I'll try jasonsbytes' idea later when I get a dev site set up.

prhodes’s picture

Just wanted to also report that jasonsbytes solution worked for me.

Thanks!

shanefjordan’s picture

One thing I have noticed with the timezone issues (US Eastern) is that there is an issue with the DST (daylight savings time). I have a list of events with dates/times and everything is great until you get to november, then everything is off by an hour. This is after i've added the code to compensate for the date_default_timezone. Anyone have any ideas how to go about correcting this? It seems to me that most of the issues are with the fact that event is doing timezones and date is doing timezone.

Thanks,
Shane

japerry’s picture

Status: Active » Closed (outdated)

Event for Drupal 8 is unrelated to older versions. If an issue similar to this one exists, please open a new issue with the 8.x branch.