Question
How do you convert a Unix timestamp (seconds since epoch) to Ruby DateTime?
Answer
DateTime.strptime
can handle seconds since epoch. The number must be
converted to a string:
require 'date'
DateTime.strptime("1318996912",'%s')
How do you convert a Unix timestamp (seconds since epoch) to Ruby DateTime?
DateTime.strptime
can handle seconds since epoch. The number must be
converted to a string:
require 'date'
DateTime.strptime("1318996912",'%s')