I've seen a few different DateTime comparisons on StackOverflow, but I can't seem to get it right. I need to be able to retrieve a row from the database, compare the DateTime with the current DateTime, and then evaluate whether or not it.
In this case, I need to check if the current row has expired or not.
if (strtotime(new DateTime()) > strtotime($row['expiration_date'])) {
$response = 'Valid Coupon!';
} else {
$response = 'Coupon Expired';
}
I've tried a few different ways, but none seem to work properly.
"2017-07-15 13:42:31 > 2017-07-15 14:27:31"
// and
"2017-07-15 13:42:31 > 2017-07-14 13:03:04"
Both return as a Valid Coupon.
I've tried a number of things, but can't seem to figure out why these dates aren't working properly. Any thoughts?