Solved

File LastModified

Posted on 2002-06-04
1
206 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…
Suggested Courses
Course of the Month10 days, 13 hours left to enroll

628 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