Skip to content

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

class method

File.birthtime

(::path | ::IO file_name) -> ::Time
File.birthtime(path) → time

Returns a new Time object containing the creation time of the entry at the given path; see File System Timestamps:

Example
filepath = '/tmp/t.tmp'
File.birthtime(filepath) # Raises Errno::ENOENT: No such file or directory.
File.write(filepath, 'foo')
File.birthtime(filepath) # => 2026-10-05 13:41:02.330337383 -0500
File.delete(filepath)    # Clean up.
See also #birthtime .basename .blockdev? .atime also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0