format.rb
Heads up: This description was created by AI and might not be 100% accurate.
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-10-11 11:55:20.877692869 +0000
t.strftime("%F")
#=> "2025-10-11"
Executed with Ruby 3.4.7
.