Compare given date with today

前端 未结 13 2140
别那么骄傲
别那么骄傲 2020-11-22 16:22

I have following

$var = \"2010-01-21 00:00:00.0\"

I\'d like to compare this date against today\'s date (i.e. I\'d like to know if this

13条回答
  •  独厮守ぢ
    2020-11-22 16:43

    $toBeComparedDate = '2014-08-12';
    $today = (new DateTime())->format('Y-m-d'); //use format whatever you are using
    $expiry = (new DateTime($toBeComparedDate))->format('Y-m-d');
    
    var_dump(strtotime($today) > strtotime($expiry)); //false or true
    

提交回复
热议问题