Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

File::Stat#birthtime

stat.birthtime → aTime

Returns the birth time for stat.

If the platform doesn’t have birthtime, raises NotImplementedError.

Example
File.write("testfile", "foo")
sleep 10
File.write("testfile", "bar")
sleep 10
File.chmod(0644, "testfile")
sleep 10
File.read("testfile")
File.stat("testfile").birthtime   #=> 2014-02-24 11:19:17 +0900
File.stat("testfile").mtime       #=> 2014-02-24 11:19:27 +0900
File.stat("testfile").ctime       #=> 2014-02-24 11:19:37 +0900
File.stat("testfile").atime       #=> 2014-02-24 11:19:47 +0900
See also #atime #blksize #<=> #blockdev? also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0