Reputation: 1226
I would like to add the last modified date to the index page , the below code shows the 31/12/1969 is the last modified date.
echo date("d/m/Y",filemtime("index.php"));
Upvotes: 4
Views: 5915
Reputation: 131861
I guess the path is wrong. At last on your development system you should increase the error settings.
In case of an erro filemtime()
returns false
, what what gets casted into 0
by the date()
-call.
You should refer your files on the filesystem using (pseudo-)absolute paths.
__DIR__ . '/path/to/index.php';
Upvotes: 4
Reputation: 1491
My guess is filemtime
is not finding your file. filemtime
will return 0, or something that equates to 0 like FALSE, and then applying date
on time 0
will return 0 seconds since the epoch (1st Jan 1970).
Looks like that's what you're getting. I'm also guessing you're using PHP <= 5.1.
Upvotes: 0