2016-01-21 137 views

回答

5

使用strtotime()

if(strtotime($date)<strtotime("today")){ 
    echo "past"; 
} elseif(strtotime($date)==strtotime("today")){ 
    echo "today"; 
} else { 
    echo "future"; 
} 
+0

它的工作原理。非常感謝你。 – user3552391

+0

不是'time()'比'strtotime(「today」)'簡單嗎? – TRiG

+1

@TRiG,'time()'會給出當前日期和**時間**,但是strtotime('Jan-21-2016')'會在當天的午夜給出日期。這會造成今天的情況。 – bakavic