Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Pathname#ctime
() -> ::Time
ctime → new_time
pathname_builtin.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/pathname_builtin.rb, line 1462
def ctime() File.ctime(@path) end
On Windows, returns the birthtime for the path in self.
On other systems, returns a new Time object containing the time of the most recent metadata change to the entry represented by self; see File System Timestamps:
Example
# A directory and its Pathname. dir_path = '/tmp/dir' dir_pn = Pathname(dir_path) # Create directory; establishes directory ctime. dir_pn.mkdir dir_pn.ctime # => 2026-10-05 16:36:52.738405306 -0500 # A file therein and its Pathname. file_path = dir_pn.join('t.tmp') # => #<Pathname:/tmp/dir/t.tmp> file_pn = Pathname(file_path) # Create file; establishes file ctime; updates directory ctime. file_pn.write('foo') file_pn.ctime # => 2026-10-05 16:38:35.076588258 -0500 dir_pn.ctime # => 2026-10-05 16:38:35.076588258 -0500 # Write file; updates file ctime; does not update directory ctime.. file_pn.write('bar') file_pn.ctime # => 2026-10-05 16:39:57.842776244 -0500 dir_pn.ctime # => 2026-10-05 16:38:35.076588258 -0500 # Read file; updates neither ctime. file_pn.read file_pn.ctime # => 2026-10-05 16:39:57.842776244 -0500 dir_pn.ctime # => 2026-10-05 16:38:35.076588258 -0500 dir_pn.rmtree # Clean up.