By harrisben on
I would like to display the date a file was last updated, but it doesn't seem to be working.
I've tried the following methods:
1. Gives an error:
warning: filemtime() [function.filemtime]: stat failed for /sites/default/files/myfile.txt in /path/to/drupal/site/includes/common.inc(1537) : eval()'d code on line 4.
and also provides the incorrect date.
<?php
// Change to the name of the file
$last_modified = filemtime("/sites/default/files/myfile.txt");
// Display the results
// eg. Last modified Monday, 27th October, 2003 @ 02:59pm
print "Last modified " . date("l, dS F, Y @ h:ia", $last_modified);
?> 2. Provides what I believe is the file creation date, but at least there's no error.
<?php
echo date( "F d Y h:i:s", getlastmod('/sites/default/files/myfile.txt') );
?>Can anyone point in the right direction?
PS please forgive my shoddy php syntax as I really have next to no clue about it.
Comments
An Update
After looking the getlastmod() function up I see that it doesn't accept any parameters and is actually designed to return the last modified date of the current file.
Any ideas on how I can get #1 to work?
Ditto
I just went through the exact same problem trying it both ways already mentioned. Any suggestions? Is clean URLs the problem?