2012-10-28 79 views
1

我需要在每週五晚上9點顯示ON AIR CONTENT,然後在12點停止並恢復到OFF AIR CONTENT。基於日期和時間段的PHP顯示內容

下面是我手動更改以使這成爲可能的兩組代碼。如果我得到正確的代碼,我可以自動執行此操作。

任何人都可以幫助我嗎?

/* 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'); 
+0

這是什麼不起作用?.... – dbf

+0

現在我在上面的空氣代碼和空氣密碼之間手動切換。我需要一個PHP日期函數來自動完成這個過程。 –

回答

0

PHP的日期(「G」)功能會給你24小時格式爲字符串的時間。然後你可以測試一下,做出你想要的任何決定。

+0

我不知道如何做到這一點。你能幫我嗎? –