Reputation: 1
How to get last modified timestamp of an external file?
I'm trying to use using xhr.getResponseHeader("Last-Modified")
, and I am getting the pervious modified time, but not the recent modified timestamp.
e.g: Fri, 02 Jun 2017 04:39:18 GMT
whereas I should get today's date.
Upvotes: 0
Views: 3057
Reputation: 1
You can use get response as a Blob
, pass Blob
to File
constructor to get .lastModifiedDate
property value
fetch("/path/to/file")
.then(response => response.blob())
.then(blob => {
const file = new File([blob], blob.name);
console.log(file.lastModifiedDate, file.lastModified);
});
Upvotes: 2