Skip to content

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

instance method

Pathname#birthtime

() -> ::Time
birthtime → new_time

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

Example
filepath = '/tmp/t.tmp'
pn = Pathname(filepath)
pn.birthtime # Raises Errno::ENOENT: No such file or directory.
pn.write('foo')
pn.birthtime # => 2026-10-05 13:45:54.459480484 -0500
pn.delete    # Clean up.
See also #binwrite #blockdev? #binread #chardev? also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0