Heads up: This description was created by AI and might not be 100% accurate.

format.rb

This Ruby code snippet demonstrates obtaining the current time and formatting it as a string. Time.now gets the current date and time. strftime("%F") then formats this time object into a date string with the format “YYYY-MM-DD”.

Ruby code snippet

t = Time.now
#=> 2025-07-27 23:54:05.132731905 +0000
t.strftime("%F")
#=> "2025-07-27"

Executed with Ruby 3.4.5.