PHP check if today is in between two dates

前端 未结 1 423
悲哀的现实
悲哀的现实 2021-01-24 10:58

Consider following code:

$today = date(\"d/m/Y\");

$start_date = \'20/11/2014\';
$time1 = strtotime($start_date1);
$start_date1 = date(\'d/m/Y\',$time1);

$end_         


        
相关标签:
1条回答
  • 2021-01-24 11:29

    Try this:

    <?php
    
        $now = new DateTime();
        $startdate = new DateTime("2014-11-20");
        $enddate = new DateTime("2015-01-20");
    
        if($startdate <= $now && $now <= $enddate) {
            echo "Yes";
        }else{
            echo "No";
        }
    
    ?>
    
    0 讨论(0)
提交回复
热议问题