Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I tried a lot - But the code at the bottom is always 1 hour behind the local time. It might be a problem of the server-time. But I want to use it for a german website - So I have to set the time to GMT +1.

It would be great if someone could help me...

    <?php 
$today = date('N');
if( $today == 1) { ?>
<article class="intro"><div class="content" style="width:auto;float:left;"><h4><?php dynamic_sidebar( 'countdown' ); ?></h4></div></article>
<?php } elseif( $today == 2 ) { ?>
<article class="intro"><div class="content" style="width:290px;"><h4><?php dynamic_sidebar( 'seitenleiste' ); ?></h4></div></article>
<?php } elseif( $today == 3 ) { ?>
<article class="intro"><div class="content" style="width:290px;"><h4><?php dynamic_sidebar( 'seitenleiste' ); ?></h4></div></article>
<?php } elseif( $today == 4 ) { ?>
<article class="intro"><div class="content" style="width:290px;"><h4><?php dynamic_sidebar( 'seitenleiste' ); ?></h4></div></article>
<?php } elseif( $today == 5 ) { ?>
<article class="intro"><div class="content" style="width:290px;"><h4><?php dynamic_sidebar( 'seitenleiste' ); ?></h4></div></article>
<?php } elseif( $today == 6 ) { ?>
<article class="intro"><div class="content" style="width:290px;"><h4><?php dynamic_sidebar( 'seitenleiste' ); ?></h4></div></article>
<?php } elseif( $today == 7 ) { ?>
<article class="intro"><div class="content" style="width:290px;"><h4><?php dynamic_sidebar( 'seitenleiste' ); ?></h4></div></article>
<?php } ?>

Thank you so much!

Philipp

share|improve this question
add comment

1 Answer

Time is one of the things in environment WordPress normalizes to GMT, so all native PHP function give that in WordPress context.

To get time in timezone, set in WordPress settings, try date_i18n() instead.

share|improve this answer
    
So do you mean something like that: <?php $today = date_i18n('N'); if( $today == 1) { ?> Thank you so much! –  Philipp Mar 20 '12 at 10:12
    
@Philipp yes, it should work just as date() but using timezone and locale from WP settings. –  Rarst Mar 20 '12 at 10:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.