Click to See Complete Forum and Search --> : file last modified question


comptech520
10-27-2006, 02:12 AM
hello,

I am using this to display when a certain file was last modified and it displays Decenber 1969. Is there a way I can get it to display the real answer which is October 2006?

This is what I have for code:

<?php
$last_modified = filemtime("/var/www/vhosts/domain.com/subdomains/songlists/httpdocs/content/top40.php");
echo "UPDATED FOR ";
echo date("F Y", $last_modified);
?>

bokeh
10-27-2006, 06:44 AM
filemtime is returning false.

comptech520
10-30-2006, 08:16 AM
Is there a way to make this work?

bokeh
10-30-2006, 08:26 AM
First you need to confirm I am correct. Then you need to look into why this is so (does the file exist, is the path good, etcetera).

comptech520
10-30-2006, 10:46 AM
The path is correct

bokeh
10-30-2006, 11:05 AM
Run: var_dump($last_modified); andvar_dump(file_exists($file)); and var_dump(is_readable($file));See what results you get.

NogDog
10-30-2006, 11:10 AM
This might at least narrow down where the problem is:

$file = '/var/www/vhosts/domain.com/subdomains/songlists/httpdocs/content/top40.php';
if(file_exists($file))
{
$last_modified = filemtime($file);
if($last_modified === FALSE)
{
user_error("Unable to get modification time for file: $file", E_USER_WARNING);
}
else
{
echo "UPDATED FOR " . date("F Y", $last_modified)
}
}
else
{
user_error("File does not exist or is not readable: $file", E_USER_WARNING);
}