IT & Programming

Get last modified date and time of a file with PHP

This small function accepts file path as parameter and returns the date and time when the file was change or alter last time.

Function

function lastModified($file) {
    
    $mtime = filemtime($file);
    echo date("D d M Y g:i A", $mtime);
}

Calling the function

echo lastModified('d:/documents/resume.doc');

Output

Fri 15 Jun 2012 7:10 PM

Leave A comment

Email address is optional and will not be published. Only add email address if you want a reply from blog author.
Please fill required fields marked with *