The Time.at()
method is used to get time in Ruby. It returns the time at a particular period depending on the parameter passed.
Time.at(param)
param
: This could be a time object or a number of seconds in Unix timestamp in the form of an integer.
The value returned is a time object.
In the example below, we’ll see how to use the Time.at()
method.
# get timea = Time.at(Time.new)b = Time.at(Time.now)c = Time.at(946702800)d = Time.at(Time.new(2002))# print resultsputs aputs bputs cputs d
Time.at()
method using Time.new
, which creates a time object.Time.now
method and pass it to the Time.at()
method.Time.at()
method.Time.new()
method and pass the result to the Time.at()
method.