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
pathname_builtin.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/pathname_builtin.rb, line 1423
def birthtime() File.birthtime(@path) end
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.