Is there a way to get the modification time of a file (either ctime
or mtime
should work) that is accessed locally through JavaScript?
I want to go to file:///home/me/mtime.html
and have the JavaScript tell me that /home/me/file.txt
was modified 2 minutes ago or something. I Understand that JavaScript has limited file access due to security problems, but is there some trick since it is all done locally.
Thanks.
Here is some javascript using ActiveX that I think might help you out:
<script language=jscript runat=server>
var thisfile = <File_Path>;
thisfile = Server.MapPath(thisfile);
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fs = fso.GetFile(thisfile);
var dlm = fs.DateLastModified;
Response.Write("Last modified: " + dlm);
</script>
If you need how long ago it was modified you would need some other javascript to subtract dlm from the current time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With