irb> dt = Time.now.utc => 2012-04-26 10:47:01 UTC irb> dti = dt.to_i => 1335437221
Now, how to convert dti back to Date/Time ?
dti
Use Time.at.
Time.at
Time.at(1335437221) # => 2012-04-26 12:47:01 +0200
How do you convert a Unix timestamp (seconds since epoch) to Ruby DateTime?
How do you convert between a DateTime and a Time object in Ruby?
I have used a ruby script to convert iso time stamp to epoch, the files that I am parsing has following time stamp structure: 2009-03-08T00:27:31.807 Since I want to keep milliseconds I used following ruby code to convert …