In Ruby, the to_f method is used to return the value of a time object as a floating-point number of seconds since the
timeObj.to_f
This method takes no parameters. It is only invoked by a time object, which in our case is timeObj.
This method returns the value of the time object timeObj as a floating-point number of seconds since the Epoch.
# create time objectst1 = Time.now # current timet2 = Time.at(946702800)t3 = Time.new(2021)# get seconds since unix epoch# in floating point# and print resultsputs t1.to_fputs t2.to_fputs t3.to_f
Time.now to method create a time object, which is the current time or the current system time .Time.at() method.Time.new() method to create a time object by passing the year 2021 to it.to_f method on the time objects, and print the results.