Heads up: This description was created by AI and might not be 100% accurate.
format.rb
This Ruby code snippet demonstrates obtaining the current date and time, then formatting it to display only the date in the format YYYY-MM-DD using the strftime
method.
Ruby code snippet
t = Time.now
#=> 2025-07-22 13:40:26.044164888 +0000
t.strftime("%F")
#=> "2025-07-22"
Executed with Ruby 3.4.5
.