How would I check if a date in the format "2008-02-16 12:59:57" is less than 24 hours ago?
if (strtotime("2008-02-16 12:59:57") >= time() - 24 * 60 * 60)
{ /*LESS*/ }
Just adding another answer, using strtotime
's relative dates:
$date = '2008-02-16 12:59:57';
if (strtotime("$date +1 day") <= time()) {
// Do something
}
I think this makes the code much more readable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With