How can I compare two dates in PHP?

前端 未结 13 2242
一整个雨季
一整个雨季 2020-11-22 06:02

How can I compare two dates in PHP?

The date is stored in the database in the following format

2011-10-2

If I wanted to

13条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 06:46

    I had that problem too and I solve it by:

    $today = date("Ymd");
    $expire = str_replace('-', '', $row->expireDate); //from db
    
    if(($today - $expire) > $NUMBER_OF_DAYS) 
    { 
        //do something; 
    }
    

提交回复
热议问题