Javascript 如何获取外部文件最后修改的时间戳?
如何获取外部文件最后修改的时间戳 我试图使用Javascript 如何获取外部文件最后修改的时间戳?,javascript,Javascript,如何获取外部文件最后修改的时间戳 我试图使用xhr.getResponseHeader(“Last Modified”),得到的是以前修改过的时间,而不是最近修改过的时间戳。 e、 g:Fri,2017年6月2日04:39:18 GMT而我应该得到今天的日期。您可以使用get response作为Blob,将Blob传递到文件构造函数以获取。lastModifiedDate属性值 fetch("/path/to/file") .then(response => response.blob(
xhr.getResponseHeader(“Last Modified”)
,得到的是以前修改过的时间,而不是最近修改过的时间戳。
e、 g:
Fri,2017年6月2日04:39:18 GMT
而我应该得到今天的日期。您可以使用get response作为Blob
,将Blob
传递到文件构造函数以获取。lastModifiedDate
属性值
fetch("/path/to/file")
.then(response => response.blob())
.then(blob => {
const file = new File([blob], blob.name);
console.log(file.lastModifiedDate, file.lastModified);
});
您可以使用get response作为Blob
,将Blob
传递到File
构造函数以获取.lastModifiedDate
属性值
fetch("/path/to/file")
.then(response => response.blob())
.then(blob => {
const file = new File([blob], blob.name);
console.log(file.lastModifiedDate, file.lastModified);
});
xhr.getResponseHeader('Last-Modified')
是正确的方法。您应该环顾四周,您的问题可能在其他地方。客户端只能通过服务器发送的内容进行轻微的格式更改。xhr.getResponseHeader('Last-Modified')
是正确的方法。您应该四处看看,您的问题可能在其他地方。客户端只能通过服务器发送的内容进行轻微的格式更改。