Hi folks,

How is daylight saving time handled in Drupal?

I've had to manually change my time zone setting to get the change to work. Is there no automatic DST capability?

Thanks,
Mike

Comments

It appears that DST was

It appears that DST was never handled in drupal. If you want it to do so you can make the same change we made:
Daylight Saving Time Adjustment

The file need to be patched: includes/common.inc.

At the end of the file, add function drupal_is_edt($timestamp).

922d921
+       if (drupal_is_edt($timestamp)) { $timestamp += 3600; }
1495,1505d1493
+
+ function drupal_is_edt($timestamp) {
+     $year = date('Y');
+     $timezone = variable_get('date_default_timezone', 0);
+     $dststart = strtotime("+1 week sunday GMT", strtotime("1 march $year GMT")) + 7200 + $timezone;
+     $dstend = strtotime("+0 week sunday GMT", strtotime("1 november $year GMT")) + 7200 + $timezone;
+     if ($dststart <= $timestamp && $timestamp <= $dstend) return 1;
+
+     return 0;
+}
+

For MEZ/+100 DST (Germany)

For MEZ/+100 DST (Germany) drupal_is_edt doesn't work properly, I think because of a different date for switching to DST. So i used instead:

function drupal_is_edt($timestamp) {
   return date('I',$timestamp);
}

This might work for sites that deal only with one (the locale) timezone. For multiple zones, there might have to be added some switch via set_locale.

Parse error: parse error, unexpected T_STRING in /home/domain/domain-www/includes/common.inc on line 1494

---

did you remove the "+" signs ?

Of course not ..

.. I just followed the instructions.

But I just now tried it again without the plus signs and got the exact same result:

"Parse error: parse error, unexpected T_STRING in /home/ccag/ccag-www/includes/common.inc on line 1494"

---

if (drupal_is_edt($timestamp)) { $timestamp += 3600; }
function drupal_is_edt($timestamp) {
$year = date('Y');
$timezone = variable_get('date_default_timezone', 0);
$dststart = strtotime("+1 week sunday GMT", strtotime("1 march $year GMT")) + 7200 + $timezone;
$dstend = strtotime("+0 week sunday GMT", strtotime("1 november $year GMT")) + 7200 + $timezone;
if ($dststart <= $timestamp && $timestamp <= $dstend) return 1;

return 0;
}

try the above code, I just tested it with no parse error, however, I cannot confirm or deny that it works as expected.

Thank you. No parse error

but didn't work, I still need GMT -0400 setting to display correct time. I'm in the eastern US so local time zone is actually GMT -0500.

And didn't mean to be a smartass above, I just tend to take things rather literally most of the time. :D

I did mention this was a

I did mention this was a patch. It was meant to be applied with the patch tools. Sorry if that was unclear.

I have never heard of 'Patch Tools'

This is the first I've heard of them, I have zero idea what they are.

I did a quick search but didn't see any documentation.

---

nobody click here