41
irb> dt = Time.now.utc
=> 2012-04-26 10:47:01 UTC

irb> dti = dt.to_i
=> 1335437221

现在,如何转换dti回日期/时间?

4

1 回答 1

116

使用Time.at.

Time.at(1335437221)
# => 2012-04-26 12:47:01 +0200 
于 2012-04-26T10:52:34.063 回答