PHP View File modification time

Source: Internet
Author: User
System files:

In development we sometimes need to know the last access time of the file and the last modified time of the file, and introduce the 3 functions that PHP provides to determine the access, creation and last modification time of the file: fileatime() , filectime() and filemtime() .
1.fileatime()
int fileatime(string filename): the Fileatime () function returns the last time the filename was accessed, where the last access refers to the time when a file's data block is read, in a timestamp UNIX format, and returned with an error FALSE .
2.filectime()
int filectime(string filename): the Filectime () function returns the last changed time, where the last change is the time of the last change of the filename specified file filename inode , where inode (the index node) the basic information used to store the file and directory includes time, file name, user and group, etc., using Timestamp UNIX format, returned when there is an error FALSE .
3.filemtime()
int filemtime(string filename): The filemtime() function returns the filename last modified time, and the last modification refers to the change of the contents of the file, using the timestamp UNIX format and returning when there is an error FALSE .
For example:


    
     $file="/software/test.txt"; echo"文件最后访问的时间是".date("Y-m-d H:i:s",fileatime($file))."
"; echo"文件最后改变的时间是".date("Y-m-d H:i:s",filectime($file))."
"; echo"文件最后修改的时间是".date("Y-m-d H:i:s",filemtime($file))."
"; ?>

Remote Files

functionremote_filectime($url_file){$headInf = get_headers($url_file,1);  //注意第二个参数 return strtotime($headInf['Last-Modified']);   

Get_headers return Data

Array(    [0] => HTTP/1.1200 OK    [Server] => nginx    02201607:34:52 GMT    [Content-Type] => text/xml    2750    [Connection] => close    02-Mar-1707:34:52 GMT; path=/    [P3P] => CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"    "Ahh8eNBCjmL"    02201609:55:40 GMT    [Accept-Ranges] => bytes)

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the PHP view file modification time, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.