如何检查日期是否晚于当前日期?
if(date("d") < "18" && date("m") < "01") {
echo 'To late!';
}
对我来说无法运行。
if( '20140505' > date("Ymd") ) {
// today's date is before 20140505 (May 5, 2014)
}
strtotime()
- 或者更好的是,使用DateTime
类。 - Amal Murali$time1 = strtotime(date("d/m/Y", "18/01/2014"));
if(time() > $time1)
{
echo "too late!";
}
$current_date = date("Y-m-d");
$date_to_compare = date("Y-m-d",time()+86400); //1 day later
if (strtotime($date_to_compare) > strtotime($current_date)) {
echo "too late";
}