Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
4 posts Page 1 of 1
Hi KK,

is there a way to handle Daylight Saving Time (e.g. in Germany) without to change 'K_GMT_OFFSET' in config.php twice a year?

Greetings
Klaus
Hi Klaus,

Instead of manually changing the offset twice an year, we can male PHP do it for us automatically.

If you are running on PHP 5.1.0 or higher (as most hosts are now a days), try replacing the following statement in couch/config.php file where we set the offset
Code: Select all
define( 'K_GMT_OFFSET', +5.5 );

with the following -
Code: Select all
// List of all supported timezones in PHP can be found here: http://www.php.net/manual/en/timezones.php

date_default_timezone_set( 'Europe/Berlin' );

if( date('I') ){
    // DST in effect
    define( 'K_GMT_OFFSET', +2 );
}
else{
    define( 'K_GMT_OFFSET', +1 );
}


Does this help?
Please let us know.

Thanks.
Hi KK,

your solution works fine.

Thanks to your solution, I found an even easier method:

Code: Select all
   date_default_timezone_set( 'Europe/Berlin' );
   define( 'K_GMT_OFFSET', date('Z')/3600 );


date ('Z') is the offset in seconds.
So you have only to set the correct timezone and the offset is always right.

Thank you for you excellent support!

Klaus
Thanks for sharing the solution with us, Nikos :)
I'll move this thread over to 'Tips and Tricks' as this seems to be a very useful technique.
4 posts Page 1 of 1
cron