LoginSignup
0
0

More than 5 years have passed since last update.

DateTimeオブジェクトで時間の加減算

Posted at

いちどTimeオブジェクトに変換してから戻してやればできた。

require 'date'
dt = DateTime.now
t = dt.to_time
one_hour_ago = t - 60*60
dt_1h_ago = one_hour_ago.to_datetime
0
0
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
0
0