7.21. Formatting and Printing Date/Time Values
You can obtain the canonical representation of the date and time by calling the asctime method ("ASCII time"); it has an alias called ctime, for those who already know it by that name.
You can obtain a similar result by calling the to_s method. This is the same as the result you would get if doing a simple puts of a date/time value.
The strftime method of class Time formats a date and time in almost any form you can think of. Other examples in this chapter have shown the use of the directives %a, %A, %U, %W, %H, %M, %S, %I, and %p; we list here all the remaining directives that strftime recognizes:
%b Abbreviated month name ("Jan") %B Full month name ("January") %c Preferred local date/time representation %d Day of the month (1..31) %j Day of the year (1..366); so-called "Julian date" %m Month as a number (1..12) %w Day of the week as a number (0..6) %x Preferred representation for date (no time) %y Two-digit year (no century) %Y Four-digit year %Z Time zone name %% A literal "%" character
For more information, consult a Ruby reference.