84
58

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RubyでUNIXTIME変換

Last updated at Posted at 2014-11-28

よく忘れるのでメモ。

1. UNIXTIMEからDATETIMEへの変換

Time.at(1414767600)
# => 2014-11-01 00:00:00 +0900

2. DATE(TIME)からUNIXTIMEへの変換

require 'time'
Time.parse('2014-11-01 00:00:00').to_i
# => 1414767600

# Dateも可能
Time.parse('2014-11-01').to_i
# => 1414767600
84
58
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
84
58

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?