Reputation: 585
I wrote a CMS script made of many folders and files and I want to find a way to track when I last modified any of the files. I wrote a recursive directory/file check that finds the latest modified file and gives me the date and time however my issue is this: every time that I as much as copy a file to the server, or rename a file, even if I didn't make any modifications at all to any of the files, the newly copied file or renamed file now has today's date and therefore my script shows that there was a modification made today even if I haven't made changes in weeks.
How can I circumvent that?
I am using filemtime()
Is there a way with PHP to know when the file was ACTUALLY last modified (ie when the code in a file was worked on the last time)? Thanks
Upvotes: 0
Views: 532
Reputation: 585
I found a way to do it and wanted to post the answer:
$test = new SplFileInfo('path/to/file');
echo $test->getMTime();
echo date('Y-m-d',$test->getMTime());
The SplFileInfo::getMTime will actually return the last time a file's contents were modified as opposed to the last modification date of the file
Upvotes: 1