[英]Get the most recent directory in JavaScript
Is there a way to get the most recent directory by date in JavaScript?有没有办法在 JavaScript 中按日期获取最新目录? Or if this not possible, the directory with the highest number?
或者,如果这不可能,则编号最高的目录?
Because I have a folder with versions, and I want to use JavaScript to select the latest version and redirect to that folder.因为我有一个包含版本的文件夹,我想使用 JavaScript 选择最新版本并重定向到该文件夹。
To be more clear, I want this because GitHub pages only supports HTML, CSS and JS.更明确地说,我想要这个是因为 GitHub 页面只支持 HTML、CSS 和 JS。
folder/
1.0/
index.html
2.0/
index.html
3.0/
index.html
index.html
Thank you in advance!先感谢您!
If you are using nodejs, you can use fs.stat(path, [callback])
which will give you mtime
as part of the stats object in the callback如果您使用的是 nodejs,则可以使用
fs.stat(path, [callback])
它将为您提供mtime
作为回调中 stats 对象的一部分
mtime
is the time at which the file/folder was last modified. mtime
是上次修改文件/文件夹的时间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.