使用PHP在新闻时段显示DIV

使用PHP在新闻时段显示DIV,php,Php,我有一个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' &

我有一个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;
  }
}
}
函数kiroj_live_news(){ $week_day=日期('w'); $current_time=日期('Hi'); $show\u news\u div=false; 如果($week\u day>=1&&$week\u day='0430'&$current\u time='1200'&$current\u time='1700'&$current\u time='2300'&$current\u time='0700'&$current\u time='1700'&$current\u time='1830'&$current\u time='2300'&$current\u time='0600'&$current\u time='1700'&$current\u time='1830'&$current\u time='2300'&' 我更改了主函数中的时间,尝试了PHP手册()中的其他日期()格式,但无法显示DIV。有人能帮忙吗

function kiroj_live_news() {

    //your code here

    ....

    return $show_news_div;

}

$display = kiroj_live_news();

......

你的函数不返回任何东西-所以它总是
FALSE

我需要做什么才能使它返回?
function kiroj_live_news() {

    //your code here

    ....

    return $show_news_div;

}

$display = kiroj_live_news();

......