Solved

File LastModified

Posted on 2002-06-04
1
196 Views
Last Modified: 2012-05-04
I am trying to use the LastModified statement to get the date of a file.  Since document.lastmodified returns the date of the current document, how do you use this to return the date of another file?

<script>document.write(FileTimeDate('demo.htm'));</script>

function FileTimeDate(f_in) {
       
    var fileName = new String(f_in);
/* ???   File f1 = new File(fileName);*/
   

/* ???   var lastmod = ???.lastModified; */
    var lastmoddate = new Date(lastmod);
    var month_long = 0;
    var month_short = 0;
    var file_mod;
   
    var day = lastmoddate.getDay();
    var month = lastmoddate.getMonth();
    var curdate = lastmoddate.getDate();
    var year = lastmoddate.getYear();
    var hour = lastmoddate.getHours();
    var minutes = lastmoddate.getMinutes();
    var mmStr = ("" + minutes);
   
    if(month==0) month_long=" January";
    if(month==1) month_long=" February";
    if(month==2) month_long=" March";
    if(month==3) month_long=" April";
    if(month==4) month_long=" May";
    if(month==5) month_long=" June";
    if(month==6) month_long=" July";
    if(month==7) month_long=" August";
    if(month==8) month_long=" September";
    if(month==9) month_long=" October";
    if(month==10) month_long=" November";
    if(month==11) month_long=" December";
   
    month_short=month+1;
   
    if(day==1) day=" Monday";
    if(day==2) day=" Tuesday";
    if(day==3) day=" Wednesday";
    if(day==4) day=" Thursday";
    if(day==5) day=" Friday";
    if(day==6) day=" Saturday";
    if(day==0) day=" Sunday";
   
    if (mmStr.length < 2) {
            minutes = "0" + minutes;
    }
   
    if (year < 1000) {
            year = year + 1900;
    }
   
    file_mod = "updated "+month_short+"/"+curdate+"/"+year;

    return file_mod;
/*    document.write(month_short+"/"+curdate+"/"+year);*/
}
0
Comment
Question by:kph1
1 Comment
 
LVL 4

Accepted Solution

by:
ckosloski earned 50 total points
ID: 7062174
You can try the following link, but it will only work in IE.

http://www.webreference.com/js/tips/001115.html
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question