是否可以使用 Ruby 读取文件的修改日期? [英] Is it possible to read a file's modification date with Ruby?
本文介绍了是否可以使用 Ruby 读取文件的修改日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用 Ruby 读取文件的修改日期?我已经成功打开了一个文本文件并用
Is it possible to read a file's modification date with Ruby? I have successfully opened a text file and captured the contents of the file with
File.open("test.txt", "r").each do |line|"
但是读取文件的修改日期会非常有用.
but it would be very useful to read the modification date of the file.
推荐答案
使用 mtime
:
File.mtime("testfile")
=> 2014-04-13 16:00:23 -0300
这篇关于是否可以使用 Ruby 读取文件的修改日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文