Skip to content

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

instance method

File#atime

() -> ::Time
atime → time

Returns a new Time object containing the time of the most recent access to self. See File System Timestamps.

Access time for a file is established when it is created, and may be updated when the file content is read:

Example
filepath = '/tmp/t.tmp'
File.exist?(filepath)       # => false
File.write(filepath, 'foo') # Establishes access time.
file = File.new(filepath)
file.atime                  # => 2026-10-04 14:48:30.323100327 -0500
file.read                   # Updates access time.
file.atime                  # => 2026-10-04 14:49:01.104340829 -0500
# Clean up.
file.close
File.delete(filepath)
See also .atime .zero? #birthtime .writable_real? also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0