PHP: Date larger than current date

后端 未结 7 861
梦毁少年i
梦毁少年i 2020-12-01 18:02

I have this code:

$curdate = \'22-02-2011\';

$mydate = \'10-10-2011\';                     

if($curdate > $mydate)
{
    echo \'

        
相关标签:
7条回答
  • 2020-12-01 18:51

    Try converting them both to timestamps first, and then compare two converted value:

    $curdate=strtotime('22-02-2011');
    $mydate=strtotime('10-10-2011');
    
    if($curdate > $mydate)
    {
        echo '<span class="status expired">Expired</span>';
    }
    

    This converts them to the number of seconds since January 1, 1970, so your comparison should work.

    0 讨论(0)
提交回复
热议问题