Solved

File LastModified

Posted on 2002-06-04
1
192 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
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…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now