我有一个WordPress站点。我需要在新闻时间展示DIV。因此,我在模板功能中具有功能。看起来这样:
function kiroj_live_news() {
$week_day = date('w');
$current_time = date('Hi');
$show_news_div = false;
if ($week_day >= 1 && $week_day <= 5)
{
if (($current_time >= '0430' && $current_time <= '0800') || ($current_time >= '1200' && $current_time <= '1300') || ($current_time >= '1700' && $current_time <= '1830') || ($current_time >= '2300' && $current_time <= '2330'))
{
$show_news_div = true;
}
}
if ($week_day == 6)
{
if (($current_time >= '0700' && $current_time <= '0830') || ($current_time >= '1700' && $current_time <= '1800') || ($current_time >= '1830' && $current_time <= '1900') || ($current_time >= '2300' && $current_time <= '2330'))
{
$show_news_div = true;
}
}
if ($week_day == 0)
{
if (($current_time >= '0600' && $current_time <= '0700') || ($current_time >= '1700' && $current_time <= '1800') || ($current_time >= '1830' && $current_time <= '1900') || ($current_time >= '2300' && $current_time <= '2359'))
{
$show_news_div = true;
}
}
}
在我要显示的区域中,我有一个IF:
<?php
$display = kiroj_live_news ();
if ($display)
{
?>
<div class="live-news"><a href="http://www.kirotv.com/videos/news/kiro-newscast-hd2/vCYwYn/" target="_blank">Breaking News</a></div>
<?php
}
?>
我已经更改了我的主要功能中的时间,从PHP手册(http://php.net/manual/manual/en/function.date.php)尝试了其他日期()格式。谁能帮忙?
function kiroj_live_news() {
//your code here
....
return $show_news_div;
}
$display = kiroj_live_news();
......
您的功能不会返回任何东西 - 所以它始终是FALSE
。