The Date Class : Date.new « Date « Ruby






The Date Class


# To create a Date object, use the new method (or its synonym civil). 
# You must require the Date class before using it. 
# The to_s method returns the date as a string.

require 'date'

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

date.to_s # => "2006-11-08"

 








Related examples in the same category

1.Use expression substitution to show the date in a user-specified format.
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.