troubleshooting Question

having problems with comparing time & date using php.

Avatar of tech1984
tech1984 asked on
7 Comments1 Solution367 ViewsLast Modified:
I have a variable that is a date stamp that is basically the modification date of a file:

$file_date = date("mdY H:i:s", filemtime("$dir/$file"));

the above will be in a loop, that checks an entire directory. I need to write another variable that would represent 15 minutes ago that I can compare with the list of files. I am trying to echo all the files that have a file mod date >= fifteen minutes ago so it would look like this

$fifteen_minutes_ago = (now - 15 minutes)

if($file_date = date("mdY H:i:s", filemtime("$dir/$file")) >= $fifteen_minutes_ago;
echo "$file<br>";

obviously I am needing the code that should go (now - 15 minutes) that could be compared to the $file_date variable to see if $file_date should be listed.

Thanks for your time!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros