我有两个日期 将2019-07-30作为开始日期,并将2019-07-31作为结束日期。 更多日期为2019-07-30 这是我的代码:
$start_date = "2019-07-30";
$end_date = "2019-07-31";
$date_now = timetodate(DT_TIME, 3); //2019-07-30
if(($date_now >= $start_date) && ($date_now <= $end_date)){
echo "promo active!";
}
以及即使开始日期我如何显示促销活动 大于等于date_now(30> = 30)
答案 0 :(得分:0)
您需要使用strtotime()
<?php
$start_date = "2019-07-29";
$end_date = "2019-07-31";
$date_now = date('Y-m-d');
if((strtotime($date_now) >= strtotime($start_date)) && (strtotime($date_now) <= strtotime($end_date))){
echo "promo active!";
}
注意:-我已将开始日期更改为29
,以向您显示它的工作方式。 (因为今天是2019年7月29日)
答案 1 :(得分:-1)
尝试
$now = strtotime(date());
$start_date = strtotime(2019-07-30);
$end_date = strtotime(2019-07-31);
$tNow = $now ;
$date_now = timetodate(DT_TIME, 3); //2019-07-30
while($tNow <= $end_date){ echo "promo active!"; }