<?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
}
?>
基本上,当今天创建日期时,它应该显示"新"图标。它们都是相同日期的回声,但跨度没有显示
尝试使用以下方式:
if (strtotime(servermonth) === 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 } ?>
应该是:
<?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>'
}
?>