【发布时间】:2010-03-01 10:18:05
【问题描述】:
我从数据库中得到这个值:
'2009-1-1 00:00:00',好吧,让我粘贴我的代码:
$fetch = mysql_fetch_assoc($result);
$db_value = $fetch['date'];//'2009-1-1 00:00:00'
$today = date('Y-m-d H:i:s'); // Todays date
如果我想比较这两个值,我应该怎么做:
if($db_value < $today){
// Do something
}
或者方法2,转换成strtotime:
if(strtotime($db_value) < strtotime($today)){
// Do someting
}
也许我的方法不正确,我应该用什么来比较两个日期?
【问题讨论】:
标签: php date comparison