1

Is there any way to get the time when file was created by PHP ?

The manual says that filectime() can not do that ?

Is there any way ?

MichaelLuthor
  • 388
  • 1
  • 5
  • 14

3 Answers3

4

filectime() will do it but if you are using windows you can get creation time but if you are using UNIX you can get the change time and that would be all.

Sankalp Mishra
  • 5,602
  • 4
  • 27
  • 58
1

Try this example On windows the CTime is the creation time, use the following:

<?php
$files = array();

foreach (new DirectoryIterator('/path') as $fileInfo) {    
    $files[$fileInfo->getFileName()] = $fileInfo->getCTime();
}

arsort($files);

This will give you the creation time of file by php

1

In PHP, you can get "File Creation Date" by:
Example:

<?php
    echo filemtime("test.txt");
    echo "<br />";
    echo "Last modified: ".date("F d Y H:i:s.",filemtime("test.txt"));
?>

You will get this type of output:

11388197
Last modified: February 01 2006 18:49:37.
Shreyas
  • 249
  • 1
  • 12