PHP根据日期和时间框架显示内容

时间:2012-10-28 21:41:04

标签: php wordpress date time

我需要每周五晚上9点显示ON AIR CONTENT,然后在早上12点停止并恢复到OFF AIR CONTENT。

以下是我手动更改的两组代码,以实现此目的。如果我得到了正确的代码,我可以自动执行此操作。

任何人都可以帮助我吗?

/* ON AIR CONTENT*/

    function banner_rotator() {
    if (is_home()) { ?>
    <div id="rotator"><iframe width="630" height="386" src="http://www.ustream.tv/embed/8805257?v=3&amp;wmode=direct?autoplay=true" scrolling="no" frameborder="0" style="border: 0px none transparent;"> </iframe> <?php if(function_exists('vslider')){ vslider('frontpage'); } ?></div>
    <div class="main">
                <!-- FIFTH EXAMPLE -->
                <div class="view view-fifth">
                    <img src="../1.jpg" />
                    <div class="mask">
                        <h2>FULLY LOADED 2012</h2>
                        <p>This event has been cancelled.</p>
                        <a href="#" class="info">Details</a>
                    </div>
                </div>
                <div class="view view-fifth">
                    <img src="../2.jpg" />
                    <div class="mask">
                        <h2>KAFINAL - FALLING IN LOVE</h2>
                        <p>"The feedback to Falling in Love has been tremendous all over. I am getting calls from people in Jamaica, the Caribbean and even in the States...</p>
                        <a href="#" class="info">Read More</a>
                    </div>
                </div>  
 </div>
<?php }
}

    add_action('thesis_hook_before_content', 'banner_rotator');

    _____________________________________________________________________________________

    /* OFF AIR CONTENT */


    function banner_rotator() {
    if (is_home()) { ?>
    <div id="rotator"> <?php if(function_exists('vslider')){ vslider('frontpage'); } ?></div>
    <div class="main">
                <!-- FIFTH EXAMPLE -->
                <div class="view view-fifth">
                    <img src="../1.jpg" alt="FULLY LOADED 2012" title="FULLY LOADED 2012" />
                    <div class="mask">
                        <h2>FULLY LOADED 2012</h2>
                        <p>This event has been cancelled.</p>
                        <a href="#" class="info">Details</a>
                    </div>
                </div>
                <div class="view view-fifth">
                    <img src="../2.jpg" alt="KAFINAL - FALLING IN LOVE" title="FULLY LOADED 2012" />
                    <div class="mask">
                        <h2>KAFINAL - FALLING IN LOVE</h2>
                        <p>"The feedback to Falling in Love has been tremendous all over. I am getting calls from people in Jamaica, the Caribbean and even in the States...</p>
                        <a href="#" class="info">Read More</a>
                    </div>
                </div>  
 </div>
<?php }
}

    add_action('thesis_hook_before_content', 'banner_rotator');

1 个答案:

答案 0 :(得分:0)

PHP日期(“G”)功能将为您提供24小时格式的字符串时间。然后,您可以测试并做出您想做的任何决定。