如果日期是x且时间大于x,则显示A,否则显示B


PHP If date is x and time is greater than x pm show A else if show B

我试图告诉一个wordpress功能显示基于一些复杂的因素(条件)的发布日期

我必须展示一个降临风格的帖子。从12月1日开始,每天都会在这个位置放置一个新的帖子。但问题是,加拿大(全部)、加拿大(不列颠哥伦比亚省)和美国的职位不同。这就是我想让它做的

时区:Edmonton

                            If date is from dec 1 5:00pm to dec 2 4:59pm {
                            if the user is in BC 
                            {show postid 1 
                            }else if the user is in USA
                            {show postid 2
                            }else{
                            show postid 3
                            }
                            }else
                            if date is from dec 2 5:00pm to dec 3 4:59pm{
                            if the user is in BC 
                            {show postid 4 
                            }else if the user is in USA
                            {show postid 5
                            }else{
                            show postid 6
                            }
                            }else.....
                            so on for 25 days (till December 25th)

我已经能够得到我想要的大部分,但我不能添加时间因素,因为我不知道足够的php现在我的代码只显示如果日期是设置&基于ip。

                            function showheroslider(){
                            date_default_timezone_set("America/Edmonton"); 
                            if (date('F, j, Y') == 'December, 1, 2016' ){
                            $userInfo = geoip_detect2_get_info_from_current_ip();
                            if ($userInfo->mostSpecificSubdivision->name == 'British Columbia'){ 
                            $adventdatepost = get_post(1123);
                            } else if ($userInfo->country->name == 'United States'){
                            $adventdatepost = get_post(1123);
                            } else {
                            $adventdatepost = get_post(1123);
                            }
                            } else 
                            if (date('F, j, Y') == 'December, 2, 2016' ){
                            $userInfo = geoip_detect2_get_info_from_current_ip();
                            if ($userInfo->mostSpecificSubdivision->name == 'British Columbia'){ 
                            $adventdatepost = get_post(1097);
                            } else if ($userInfo->country->name == 'United States'){
                            $adventdatepost = get_post(1097);
                            } else {
                            $adventdatepost = get_post(1097);
                            }
                            } else
                            if (date('F, j, Y') == 'December, 3, 2016' ){
                            $userInfo = geoip_detect2_get_info_from_current_ip();
                            if ($userInfo->mostSpecificSubdivision->name == 'British Columbia'){ 
                            $adventdatepost = get_post(1206);
                            } else if ($userInfo->country->name == 'United States'){
                            $adventdatepost = get_post(1204);
                            } else {
                            $adventdatepost = get_post(1206);
                            }else .......

总结这个问题是:1. 而不是仅仅在日期上,我需要它显示基于日期和时间2. 如果这不是太复杂,我想实际上能够编辑这个工作在每个月的日子,而不是只有12月。(意思是每月1日下午5点到每月2日下午4点59分显示这个…)

点1优先。请帮助我,因为我已经尽了最大的努力来到这里。但我不知道如何解决时间问题。

这是我的发现。我还不是百分之百确定,但我认为这是可行的

if((date('j') == 25 && date('G') >= 17) || (date('j') == 26 && date('G') < 17)){ 
$adventdatepost = get_post('insert id for day 25);
}
else 
{
$adventdatepost = get_post('insert id for the post I want till 30 or 31st');
}

这告诉它如果一个月的一天是1,时间大于5pm,或者如果日期是2,时间小于5pm…显示第1天的邮件

依此类推,直到25天。然后在第25天之后,它可以发布特定的帖子,直到这个月的下一个1天。