Reputation: 67
i have two value date 2019-07-30 as startdate and 2019-07-31 as enddate. 2019-07-30 more is date now. and this my code :
$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!";
}
and how i display promo active even though startdate bigger equal to date_now (30 >= 30)
Upvotes: 0
Views: 85
Reputation: 72299
You need to use 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!";
}
Output:- https://3v4l.org/cX5ed
Note:- I have changed start date to 29
to show you how it will work. (as today is 29 july 2019)
Upvotes: 2