Get date of file in plugin directory

I’m attempting to get the modified date of the manifest but it’s returning Invalid Date.

Does this look correct:

try {

  const pluginFolder = await fileSystem.getPluginFolder();
  const folder = await pluginFolder.getEntry(filePath);
  var value = null;
  var entry = null;
  var metadata = null;

  if (folder.isFolder) {
	 entry = await folder.getEntry(filename);
	 value = await entry.read();
	 metadata = await entry.getMetadata();
	 console.log("metadata dateModified:",metadata.dateModified); // Invalid Date
  }
}
catch (error) {
}

Your code is correct. I verified that this is a bug. Both dateCreated and dateModified are null when returned by getPluginFolder(). Thanks for reporting it! Also, I know there is an open bug that if you get the entries from getFolder(), then the dateCreated and dateModified will not be null, but will be 369 years in the future!

1 Like