Приглашаем посетить
CSS (css.find-info.ru)

Section 13.6.  Retrieving File Time Information

Previous
Table of Contents
Next

13.6. Retrieving File Time Information

Most filesystems store the time that each file was last accessed and last modified, often referred to as "atime" for the last access time and "mtime" for the last modification time. These are accessible through the PHP functions fileatime( ) and filemtime( ). These return a Unix timestamp for the time, which you then need to convert using a call to date( ), like this:

    $contacts = "contacts.txt";
    $atime = fileatime($contacts);
    $mtime = filemtime($contacts);

    $atime_str = date("F jS Y H:i:s", $atime);
    $mtime_str = date("F jS Y H:i:s", $mtime);
    // eg June 8th 2005 16:04:15

    print "File last accessed: $atime_str\n";
    print "File last modified: $mtime_str\n";

Note that some people disable "atime" on their filesystem as a performance optimization, making this data potentially unreliable. In this situation, you will still get a date and time returned for the "atime"; it is just likely to be out of date.


Previous
Table of Contents
Next