PHP Compare two dates in format 2011-05-16T09:39:14+0000 (facebook datetime format)
In PHP开发者_运维问答 I want to compare 2 dates in this format: 2011-05-16T09:39:14+0000
$datedeb="2011-05-18T01:25:18+0000";
$datefin="2011-05-16T09:39:14+0000";
I have PHP5.1.6 for your information.
You can use PHP's strtotime function. This converts them into the timestamps, which means you can compare them like normal numbers
$datedeb = strtotime("2011-05-18T01:25:18+0000");
$datefin = strtotime("2011-05-16T09:39:14+0000");
if ($datedeb > $datefin) {
//$datedeb is larger (later) than $datefin
}
精彩评论