Scriptplayground

 Print Page | Close Window

Last Modified Info

This tutorial will show you how to display the date/time that the file was last modified.

Here you go, I commented each line, if you have a question don't hesitate to ask.

<?php

// The file to that will read.
$file = 'thefile.php';

// The variable that holds the function to display the date modified info.
$last_time_modified = filemtime($file);

// Format that time and date into a human readable format
$last_mod =  "Page last edited " . date("m/j/y h:i", $last_time_modified);

// print the new formatted string and display the last modified info. 
//You could also pass the "$last_mod" variable to another piece of your script
print $last_mod;

?>


That is the end of the tutorial. I hope you have an understanding of how "filemtime" works.


Find this article at:
http://scriptplayground.com/tutorials/php/Last-Modified-Info/