The DateLastModified property of Javascript FileSystemObject (FSO) associated with file object or folder object returns the combined result of date and time of a specified file or folder when it was last modified. DateLastModified property is accessible through both types of objects i.e. file object as well as folder object that returns the date and time when it was last modified. Javascript FSO GetFile method returns the File object that allows the access to DateLastModified property and GetFolder method returns the folder object that also supports this property.
Syntax for Javascript FSO DateLastModified Property
fileObj.DateLastModified // or folderObj.DateLastModified
Both above syntaxes show the way of using the file object and folder object to access the DateLastModified property.
Example 1
File Object to get the value of DateLastModified Property
<script type="text/javascript">
// initialize ActiveXObject and create an object of Scripting.FileSystemObject.
var fso = new ActiveXObject("Scripting.FileSystemObject");
// object created for file object returned by GetFile method
var fileObj = fso.GetFile("C:\\Temp\\textFile.txt");
document.write("<b>File DateLastModified: </b>"
+ fileObj.DateLastModified);
document.write("<br />");
// Output:
// File DateLastModified: Wed Oct 1 01:13:24 EDT 2008
</script>
Example 2
Folder Object to get the value of DateLastModified Property
<script type="text/javascript">
// initialize ActiveXObject and create an object of Scripting.FileSystemObject.
var fso = new ActiveXObject("Scripting.FileSystemObject");
// object created for folder object returned by GetFolder method
var folderObj = fso.GetFolder("C:\\Temp\\myFolder");
document.write("<b>Folder DateLastModified: </b>"
+ folderObj.DateLastModified);
document.write("<br />");
// Output:
// Folder DateLastModified: Tue Sep 30 07:04:45 EDT 2008
</script>
Continue to next tutorial: Javascript FSO Drive Property to learn how to get the drive from the specified file path or folder path.