Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

File::Stat#birthtime

() -> ::Time
birthtime → new_time

Returns a new Time object containing the creation time of the snapshot in self. See File System Timestamps:

Example
filepath = '/tmp/t.tmp'
File.write(filepath, 'foo')
stat = File.stat(filepath) # Take shapshot.
stat.birthtime             # => 2026-10-05 13:14:24.844158315 -0500
File.delete(filepath)
stat.birthtime             # => 2026-10-05 13:14:24.844158315 -0500  # Unchanged.

Ruby version changes

  1. 4.0
See also #atime #blksize #<=> #blockdev? also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0