Answer by Mitchell McKenna for Codeigniter: Compare a MySql Datetime with Current Date

October 7 2010, 8:35pm

Check out the PHP date_diff() function, for example:

$datetime1 = date_create('2009-10-11'); $datetime2 = date_create('2009-10-13'); $interval = date_diff($datetime1, $datetime2); echo $interval->format('%R%d days');

The above example will output:

+2 days

You can get the current time using getdate().