To format a date into the ISO 8601 format 'yyyy-mm-dd' in Ruby, you can use the strftime
method. Here's an example:
main.rb75 chars4 lines
This will output the current date in the 'yyyy-mm-dd' format:
main.rb11 chars2 lines
The %F
format specifier is a shortcut for %Y-%m-%d
, which represents the year, month, and day of the month, separated by hyphens. You can also use other format specifiers to customize the output.
gistlibby LogSnag