datasource.fileLastModified
Retrieves the last modified timestamp of a specified file from the MODLR filesystem.
js
datasource.fileLastModified(file_name)
Parameters
file_name
(string): The name of the file for which you want to retrieve the last modified timestamp.
Returns
number
: An integer representing the last modified timestamp of the file in milliseconds since the Unix epoch (January 1, 1970, 00:00:00 GMT). Returns0
if the file is invalid or an error occurs.
Examples
js
var lastModifiedTimestamp = datasource.fileLastModified("my_file.txt");
if (lastModifiedTimestamp > 0) {
var lastModifiedDate = new Date(lastModifiedTimestamp);
console.log("File was last modified on:", lastModifiedDate);
} else {
console.log("Error retrieving last modified date or invalid file.");
}