API経由で取得した日付情報(String)を扱う時とか。
いつも忘れるのでメモ。
String to Time
Time.parse()
# Time to String
> str = Time.now.to_s
=> "2014-04-07 10:00:00"
# String to Time
> time = Time.parse(str)
=> 2014-04-07 10:00:00 +0900
UnixTimestamp to Time
Time.at()
# Time to UnixTimestamp
> unixtime = Time.now.to_i
=> 1396832400
# UnixTimestamp to Time
> time = Time.at(unixtime)
=> 2014-04-07 10:00:00 +0900