Ashish's blog
Ashish's blog: "And how are dates stored?"
Hi Ashish, raj here. Here is your doubt that cheered me while answering.
below is the code for printing date:
------------------------------------
require 'date'
#d = Date.new(2000, 3, 31)
d = Date.today()
puts d
------------------------------------
#To print time:
puts Time.at(0)
#here in bracket you can set the seconds with time. just put some random number n try to analyze output.
------------------------------------


1 Comments:
Hi Raj,
Thanks for your reply. I tried the Date program as follows:
d = Date.today()
puts d
This gives me the following error:
>ruby DT.rb
DT.rb:1: undefined method `today' for Date:Class (NoMethodError)
>Exit code: 1
Any ideas?
Good to know that there is a Date class though. It will come handy.
Regards,
Ashish.
1:21 PM
Post a Comment
<< Home