web-dev-qa-db-fra.com

Ruby: convertir l'horodatage Unix à ce jour

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

irb> dti = dt.to_i
=> 1335437221

Maintenant, comment reconvertir dti en date/heure?

37
Paul

Utilisation Time.at .

Time.at(1335437221)
# => 2012-04-26 12:47:01 +0200 
108
Simone Carletti