Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Rails を使用していない場合、Ruby で Time.zone を使用するにはどうすればよいですか?
と思いました
require 'time'
これを修正してルビーで利用できるようにしますが、そうではなく、
NoMethodError: undefined method `zone' for Time:Class
わかりません、どういう意味ですか。しかし、私はそれが以下のように動作するはずだと思います:
(arup~>~)$ pry --simple-prompt >> Time.now => 2014-04-09 23:19:04 +0530 >> Time.now.strftime('%Z') => "IST" >> Time.now.strftime('%z') => "+0530" >> Time.now.zone => "IST"
ドキュメンテーション :#strftimeおよび#zone.
#strftime
#zone