Get File Creation & Modification Date With PHP Code Examples

Get File Creation, Modification, and Access Date PHP Code Example Here’s a featured example of how to get file dates in PHP.  $file_stats = stat('my-file.txt'); if(!$file_stats) { echo 'Failed get file information'; } else { echo 'The file was created on: '.date('d-m-Y h:m:i A',$file_stats["ctime"]).PHP_EOL; //Equivalent of filectime() echo 'The file was last modified on: '.date('d-m-Y h:m:i A',$file_stats["mtime"]).PHP_EOL; //Equivalent of filemtime() echo 'The file was last accessed on: '.date('d-m-Y h:m:i A',$file_stats["atime"]).PHP_EOL; //Equivalent of fileatime() } /* OUTPUT The file was created on: 13-09-2022 08:09:23 PM The file was last modified on: 13-09-2022 09:09:35 PM The file was last accessed on: 13-09-2022 09:09:36 PM */ Why are file dates significant? The article tries to answer this question, so stay tuned if you’re curious about it. Relevant Content: PHP File System Functions PHP has a huge library of FileSystem functions for various use cases involving files. You can get file creation, modification and…

read more