Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

File LastModified

Posted on 2002-06-04
1
Medium Priority
?
207 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 150 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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

715 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