32
21

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で現在日時を取得する

Posted at

ruby 2.1

タイムゾーンは環境変数'TZ'に依存するため注意すること

現在日付

require 'date'
Date.today

現在日時(Date)

require 'date'
Date.today.to_time

現在日時(Time)

require 'date'
Time.now

UNIX時間

require 'date'
Time.now.to_i
Date.today.to_time.to_i
32
21
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
32
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?