如果创建日期和本地日期是相同的PHP显示图标

<?php
    date_default_timezone_set('America/New York');
    $servermonth = date('m/d/Y ', time());

    $createdate = new DateTime($row['createdon']);
    $newdateformat =$createdate->format('m/d/Y') ;

    // echo $newdateformat;
    //  echo $servermonth;  
    if (servermonth == newdateformat) { 
?>
      <span class="label label-default">New</span> 
<?php  
    } 
?>

basically it should show the "New " icon when the date is created today. they are both echo-ing the same date but the span is not showing up

Try using this:

if (strtotime(servermonth) === strtotime(newdateformat)) {
   echo '<span class="label label-default">New</span>';
}

It should be:

<?php
    date_default_timezone_set('America/New York');
    $servermonth = date('m/d/Y ', time());

    $createdate = new DateTime($row['createdon']);
    $newdateformat = $createdate->format('m/d/Y') ;

    // echo $newdateformat;
    // echo $servermonth;  
    if (strtotime($sservermonth) == strtotime($newdateformat)) {
        echo '<span class="label label-default">New</span>'
    }
?>
<?php
     date_default_timezone_set('America/New York');
    $servermonth = date('m/d/Y ', time());

    $createdate = new DateTime($row['createdon']);
      $newdateformat =$createdate->format('m/d/Y') ;

    // echo $newdateformat;
   //  echo $servermonth;  
  if (strtotime($servermonth) == strtotime($newdateformat)) { ?>
  <span class="label label-default">New</span> 

  <?php  } ?>