How to read last modified date of a file using php

Post Reply
User avatar
Saman
Lieutenant Colonel
Lieutenant Colonel
Posts: 828
Joined: Fri Jul 31, 2009 10:32 pm
Location: Mount Lavinia

How to read last modified date of a file using php

Post by Saman » Fri Jul 15, 2011 6:31 pm

Outputs the date and time that a file was last modified. Can be formatted however you wish.

Code: Select all

<?php 
 
// Change to the name of the file 
$last_modified = filemtime("thisfile.php"); 
 
// Display the results 
// eg. Last modified Monday, 27th October, 2003 @ 02:59pm 
print "Last modified " . date("l, dS F, Y @ h:ia", $last_modified); 
 
?>
Post Reply

Return to “PHP & MySQL”