Use expression substitution to show the date in a user-specified format. : Date.new « Date « Ruby






Use expression substitution to show the date in a user-specified format.


# This line of code uses the month, day, and year methods from Date.

require 'date'

date = Date.new( 2006, 11, 8 )

puts "The date was #{date.month}/#{date.day}/#{date.year}."

 








Related examples in the same category

1.The Date Class
2.Calendar forms
3.In Italy, 4 Oct 1582 was immediately followed by 15 Oct 1582.
4.In England, 2 Sep 1752 was immediately followed by 14 Sep 1752.