开发者

How do I show an external file creation date on website?

I am using this site template to create a mobile/iPhone friendly site. I want to have it link to files, and below the link I want it to show the creation date. Currently everything is working fine but everytime I upload the file I also have to go into the index.html and change the modification date. Is there any type of script to do this for me that will work on my site? I have very basic HTML understanding, hence why I am using a 开发者_StackOverflowtemplate.

Thanks!


you're going to need some server-side scripting like PHP or ASP.NET. Using that, there are built-in File IO libraries where you can get the creation/modified date.


There are 2 ways to show file's last modification date (and only one of them works for creation).

  1. You can have a file list generated by the file-listing capability of your web server. Basically, any URL mapping to a directory that is permitted to show its contents will result in a web page listing the directory contents, like this:

    Index of /images/appimages/MastheadButtons
     Name                    Last modified       Size  Description
    -------------------------------------------------------------------
     Parent Directory        22-Jun-2010 09:35      -  
     GP.JPG  [link]          22-Jun-2010 09:41     1k  
     web.jpg [link]          29-Jan-2003 15:28    17k  
    
  2. You can have a back-end (CGI) script which produces the HTML page print any info you wish.

    If you only know HTML, the second approach would not be practical for you. If you know some programming language in which to write web apps (PHP, Perl, anything), you can ask a more targeted qyestion of how to achieve what you want in that language.

  3. However, HTML by itself is running on your browser. It doesn't execute any code on the web server where the file lives and thus doesn't know anything about the files.


Found the solution: I changed the file extension to .php from the iPhone Website template and then inserted this code where I want the modification date to be:

<?= date("m/d/Y H:i:s",filemtime("filename.extension")) ?>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜