0

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

1

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.

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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