duanke8011 2014-12-01 10:27
浏览 44
已采纳

too long

I'm trying to make a script to display specific messages at specific day and time. I've got the script working to display at a specific day and at a specific time, but not the two combined.

How can I make the script display a specific message at mondays between 3pm and 4pm?

Look at the script I made so far;

<?php
//Messages
$afternoon = "It's afternoon";
$evening = "It's evening";
$night = "It's night.";
$morning = "It's morning!";
$friday = "Soon weekend!";

//Get time
$current_time = date(G);
//Get day
$current_day = date(l);

//12PM - 4PM
if ($current_time >= 12 && $current_time <= 16) {
echo $afternoon;
}
//5PM - 11PM
elseif ($current_time >= 17 && $current_time <= 24) {
echo $evening;
}
//00AM - 05AM
elseif ($current_time >= 1 && $current_time <= 5) {
echo $night;
}
//6AM - 11AM
elseif ($current_time >= 6 && $current_time <= 11) {
echo $morning;
}

//Friday, display message
if ($current_day == "Friday") {
echo $friday;
}
?>

I appreciate any help I can get!

  • 写回答

3条回答 默认 最新

  • dongluan5740 2014-12-01 10:34
    关注
    if ($current_day == "Monday") {
        if ($current_time >= 15 && $current_time <= 16) {
            echo "It's Monday and the time is between 3PM and 4PM.";
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料