www www - 1 year ago 114
Ruby Question

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

We can do this:

i = Time.now.to_i

for example current:

i = 1274335854

can I convert i back to time?

Answer Source

Use Time.at:

t = Time.at(i)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download