Monday, 8 February 2016

PHP comparing if 2 files were modified in X amount of time of each other

So I have 2 files and want to know that they were created at the same time, although there may be a small gap between them, let's say not over 2 mins.

filemtime(filename) - will give us a Unix time stamp.  So

$file_1_timestamp = filemtime($path_to_file1);
$file_2_timestamp = filemtime($path_to_file2);

If ( $file_1_timestamp > $file_2_timestamp-120 && $file_1_timestamp < $file_2_timestamp+120 ) {



No comments: