PHP obtains the last update time of remote files.

Source: Internet
Author: User
Content-Length is the file size. Therefore, you can obtain the file size echostrtotime ($ headInf ['last-modified']) from the file header. // output the Last UNIX timestamp.

$ Url = 'http: // www.js4j.com/index.html ';
$ HeadInf = get_headers ($ url, 1); // get the file header information
Print_r ($ headInf); // Print the file header information
Echo "\ n ";
Echo $ headInf ['last-modified']; // The Last update time of the output file.
Echo "\ n ";
Echo strtotime ($ headInf ['last-modified']); // output the UNIX timestamp of the Last update time.
?>

Running result:

Content from js4j.com

 

Array
(
[0] => HTTP/1.0 200 OK
[Date] => Thu, 24 Apr 2008 12:12:31 GMT
[Server] => Apache/2.0.54 (Unix)
[Last-Modified] => Wed, 23 Apr 2008 16:49:41 GMT
[ETag] => "c3fdc1-1bd6-1e7fb340"
[Accept-Ranges] => bytes
[Content-Length] = & gt; 7126
[Content-Type] => text/html
[Age] = & gt; 11394
[X-Cache] => HIT from webfront4.js4j.com.cn
[Connection] => close
)

 

 

Wed, 23 Apr 2008 16:49:41 GMT
1208969381

Content-Length is the file size, so you can get the file size from the file header.

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.