Code Snippet: Compare Date in PHP
Here’s a quick way of comparing two different dates on PHP. This is usually used in rental systems to determine over dues.

< ?php
$endDate = "2009-11-25";
$curDate = date('Y-m-d',strtotime("Now"));
if ($curDate > $dueDate){
print date('M d, Y', strtotime($curDate)) . ' is greater than '. date('M d, Y', strtotime($endDate))."\n\n";
} else {
print date('M d, Y', strtotime($endDate)) . ' is greater than ' . date('M d, Y', strtotime($curDate))."\n\n";
}
?>
Spread the word
del.icio.us Digg Furl Google StumbleUpon Technorati Windows Live Yahoo! Help











Leave a Comment