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.
私は次のようなことをしたいと思っています:
Date.today.at_beginning_of_month.to_time.+2.hours.to_i
私が含めるとき
.to_i
方法私が探しているUNIX時間を取得できません。
.to_iは2.hours式にバインドされ、Fixnum(7200)になります。TimeオブジェクトにFixnumを追加すると、別のTimeオブジェクトが取得されます。
目的の結果を得るには、式を括弧で囲みます。
(Date.today.at_beginning_of_month.to_time + 2.hours).to_i