How to compare two dates in php

前端 未结 15 2592
臣服心动
臣服心动 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:24

    The date_diff() function returns the difference between two DateTime objects.

    If the first date is before the second date a positive number of days will be returned; otherwise a negative number of days:

    format("%R%a days");
    ?>
    

    output will be "+272 days" ;

    changing $date1 = "2014-03-15"

     format("%R%a days");
        ?>
    

    Output will be "-93 days"

提交回复
热议问题