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#ctime

() -> ::Time
ctime → new_time

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.
See also #cleanpath #delete #chown #descend also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0