$set_time = 2592000; # 30 days in epoch time modify for taste $current_date = time; $create_date = stat($_)->ctime; if ($create_date < ($current_date - $set_time)) { # deletion stuff here }