php file created date code example

Example 1: filemtime($current_file_name);

<?php
// outputs e.g.  somefile.txt was last modified: December 29 2002 22:16:23.

$filename = 'somefile.txt';
if (file_exists($filename)) {
    echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename));
}
?>

Example 2: php get file created date

$filename = 'somefile.txt';
if (file_exists($filename)) {
    echo "$filename last modified: ".date ("F d Y H:i:s.", filemtime($filename));
  	// somefile.txt was last changed: December 29 2020 22:16:23.
}
// filectime: when created
// filemtime: last modified
// fileatime: last accessed

Tags:

Php Example