PHP File Last Modified and Filesize (bytes to KB/MB)

$file = 'image.jpg';  
  
// File Last Modified Time  
$filetime = filemtime($file); // displays in seconds since the Unix Epoch  
echo date("M j, Y", $filetime); // would display the file creation/modified date as Feb 3, 2007  
  
// File Sizes
$filesize = filesize($file); // displays in bytes  
echo round(($filesize / 1024), 2); // bytes to KB  
echo round(($filesize / 1048576), 2); // bytes to MB  
echo round(($filesize / 1073741824), 2); // bytes to GB  

comments powered by Disqus