开发者

Last Modified Date of a File

So...On my page I currently have:

<script type="text/javascript">
document.write(document.lastModified);
</script>

This displays the last modified date of my webpages index.html.

I now want to display the last modified date of another file on my server. How do I do this?

I tried:

开发者_开发问答
<SCRIPT LANGUAGE="JavaScript">
<!--
myActiveXObject = new ActiveXObject("Scripting.FileSystemObject");
file = myActiveXObject.GetFile("My File.xlsx");
document.write(file.DateLastModified);
// -->

However it shows a bogus last modified date.


The MDN page about document.lastModified states that the property is "not part of any standard", so I'm not sure it will be reliable across all browsers. The MSDN article on the lastModified property says the same thing.

I think the only reliable way to get the last modified date of an arbitrary file is on the server side.


<?php
      $url = 'URL LINK OF WEB PAGE';

      echo ("<pre>");
      $a= (get_headers($url,1));

      $c =$a['Last-Modified'];
      echo ("<p>");
      print_r ($c);

?>

This is the PHP sentence that will help you.


You really can't without making another request via AJAX via the web server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜