You can simply do:
the_time = Time.at(1296524384)
This gives you:
2011-01-31 20:39:44 -0500
By the way, it 1296524384is called UNIX or era. It measures the number of seconds elapsed since January 1, 1970.
To format it a little better, you can use the Ruby method strftime.
the_time = Time.at(1296524384).strftime("The date is %m/%d/%Y")
Additional information here: http://apidock.com/ruby/DateTime/strftime
source
share