Check if the time has passed since the date more than X days
I need to create a PHP script that pulls timestamps from different stuff from the database (logs, messages, logins, etc.) and removes them if they are older than X days. I am poor at dealing with time and I am a little obsessed with how to do this.
I realize I can split the day / month / year on a string using explode () and compare them to a bunch of If statements, but would like to use a more efficient method. Something like the following would be the correct way to do it right?
$dt = "2011-03-19 10:05:44";
//if $dt is older than 90 days
if((time()-(60*24*90)) > strtotime($dt))
{
}
Subtract (minutes * hours * days) from time () or are the numbers wrong?
+3
user470760
source
to share