How to convert a float into time

Hello,

I am querying from the database which is storing time in double format.
I need to convert this to time format. I was able to convert time into
float but not able to convert the float into time format.

Regards,
Madhusudhan.

Madhusudhan H R wrote:

I am querying from the database which is storing time in double format.
I need to convert this to time format. I was able to convert time into
float but not able to convert the float into time format.

$ irb --simple-prompt

now = Time.now.to_f
=> 1270643035.04671

Time.at(now)
=> Wed Apr 07 13:23:55 +0100 2010

Thank you.

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