Solved

File LastModified

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

867 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

15 Experts available now in Live!

Get 1:1 Help Now