我有一个从数据库中提取的日期。我想检查该日期是否超过一年。
我已完成以下操作,但我确定我的逻辑不正确。
if (strtotime($horsesplaced1['Date']) < strtotime('-1 year')) {
//true
$placed .= "/";
$stopyear = "yes";
}
最佳答案
像这样尝试:
<?
$dbDate = '2014-01-20 17:14:40';
if(strtotime($dbDate)<strtotime('-1 year')){
echo "YES";
}else{
echo "NOP";
}
?>
关于PHP:检查日期是否早于一年,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28088697/