Reply to comment
Drupal 6.4 date rendering... ignores timezones.
Submitted by schettino on September 10, 2008 - 10:11pmMaybe it's me. Maybe I've done something wrong in the install of Drupal. It just never seems to honor the timezone setting when rendering dates. I posted this over at the drupal site, but if you happen to have the same problem, this is the hack I did to fix it at my site. Edit... nope. Something is still fishy. Maybe its just a problem with ScribeFire? Who knows.
I took a look at includes/common.inc where the format_date function lives. Every place that computes the time in that function uses gmdate(), which returns the date in GMT - ie, it ignores your timezone setting. Changing that to date() fixed all the dates just fine.
if (strpos('AaDlM', $c) !== FALSE) {
//$date .= t(gmdate($c, $timestamp), array(), $langcode);
$date .= t(date($c, $timestamp), array(), $langcode);
}
else if ($c == 'F') {
// Special treatment for long month names: May is both an abbreviation
// and a full month name in English, but other languages have
// different abbreviations.
//$date .= trim(t('!long-month-name '. gmdate($c, $timestamp), array('!long-month-name' => ''), $langcode));
$date .= trim(t('!long-month-name '. date($c, $timestamp), array('!long-month-name' => ''), $langcode));
}
else if (strpos('BdgGhHiIjLmnsStTUwWYyz', $c) !== FALSE) {
//$date .= gmdate($c, $timestamp);
$date .= date($c, $timestamp);
}
It's 5:25am local time for me now (don't ask!) Now I'm getting...
"Recent Posts" list: Blog entry Drupal death spiral schettino 0 9 hours 31 min ago
"Node render": Submitted by schettino on September 10, 2008 - 7:50pm
Which is perfect. This can't be a bug. Why are they using gmdate() to render the date, thus ignoring the timezone setting??? The Id on my copy of includes/common.inc is
// $Id: common.inc,v 1.756.2.24 2008/08/13 23:59:12 drumm Exp $