Getting error using Time.local

I am learning Ruby from a book called “Apress Beginning Ruby from Novice
to Professional 2nd edition” in that they have given an example which
is:

Time.local(year, month, day, hour, min, sec, msec)

When I am trying the above example I am getting the below error. How to
solve this issue? Please help.

irb(main):022:0> Time.local(year, month, day, hour, min, sec, msec)
NameError: undefined local variable or method year' for main:Object from (irb):22 from D:/Ruby200-x64/bin/irb:12:in

You need to define the variable “year” or implement a method called
“year” that will return a value. Typically you would do

year = 2014
month = 3

puts Time.local(year, month, day, hour, min, sec, msec)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs