I am trying to get the time stamp using filemtime() of each file and display it on the web page in PHP, I tried much as possible but only getting 1 Jan 1970 as time stamp in return.
Which basically means the timestamp function is not getting the file.
Could you please fix anything wrong in the code. Thanks
Rahil
foreach($images as $image)
{
$count+=1;
if($count==1)
{
echo '<div class="box boxgallery">';
}
/* ATTEMPT ONE*/
:clearstatcache();
$path="A2storage/'.$image.'";
$date = date(filemtime($path));
echo "Captured at: " . date('h:i A', $date);
/* ATTEMPT TWO:*/
echo date ("H:i:s | ", filemtime($image));
print basename($image) ."<br />";
echo '<a class="vlightbox1" href="A2storage/'.$image.'"/> <img src="A2storage/'.$image.'"/></a>';
if($count>=$count_each_column)
{
$count=0;
echo '</div>';
}
}
There are unwanted single quotes in value of $path
$path="A2storage/'.$image.'";
Change to
$path="A2storage/$image";
Also 1st parameter of date
function should be format which is missing.
$date = date(filemtime($path));
Change to
$date = filemtime($path);
Then this should print the time
echo "Captured at: " . date('h:i A', $date);