Ruby / Rails: convert int to time OR get time from integer?

www picture www · May 20, 2010 · Viewed 74.1k times · Source

We can do this:

i = Time.now.to_i 

for example current:

i = 1274335854

can I convert i back to time?

Answer

Mark Byers picture Mark Byers · May 20, 2010

Use Time.at:

t = Time.at(i)