How to compare two dates in php

前端 未结 15 2652
臣服心动
臣服心动 2020-11-22 08:37

How to compare two dates in php if dates are in format \'03_01_12\' and \'31_12_11\' .

I am using this code:

$date1=date(\'         


        
15条回答
  •  借酒劲吻你
    2020-11-22 09:33

    Try this

    $data1 = strtotime(\date("d/m/Y"));
    $data1 = date_create($data1);
    $data2 = date_create("21/06/2017");
    
    if($data1 < $data2){
        return "The most current date is date1";
    }
    
    return "The most current date is date2";
    

提交回复
热议问题