Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello!
My chat is two hours slower or behind the rest of the site, while a forum post can be logged at 15:51, the chat would say someone wrote something at 13:51. Both should obviously have the same time, at 15:51 if they were posted at the same time. Nothing I do, seems to rectify the clock skew of the chat.
Let me know if you require further feedback.
Best regards,
Ao
Comment | File | Size | Author |
---|---|---|---|
#3 | timezone.patch | 692 bytes | torrance123 |
Comments
Comment #1
Yasl CreditAttribution: Yasl commentedDrupal 7 variable_get('date_default_timezone', 0) returns string name and not an offset in seconds. Ugh.
It's showing UTC instead of local time I believe.
I used info from http://forum.civicrm.org/index.php?topic=20462.0
and I just hardwired my offset into the module.
function chatroom_get_user_timezone_offset() {
global $user;
$offset = variable_get('date_default_timezone', 0);
$offset = -25200; // -7(offset) * 60 * 60
if (variable_get('configurable_timezones', TRUE) && isset($user->timezone)) {
$offset = $user->timezone;
}
return $offset;
}
Now to get the day to show as many of our chats are over the course of days.
ok...changed the return in the chatroom_get_message_time_string function to:
return $date->format(variable_get('chatroom_msg_date_format', 'M:d:h:i:s:a'));
using this link to figure out - http://php.net/manual/en/function.date.php
All is well. :)
Comment #2
Aonoa CreditAttribution: Aonoa commentedThank you!
I just changed the date format slightly in variation with yours.. 'M-d H:i:s:a'. :-)
Best regards,
Ao
Comment #3
torrance123 CreditAttribution: torrance123 commentedI've attached a patch against the latest commit in 7.x-1.x which is a general solution to this problem.
See below for the new function:
Comment #4
michlis CreditAttribution: michlis commentedSolution provided by @torrance123 fixes time offset problem in 7.x-2.0.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedthanks! committed and pushed.