LoginSignup
1
1

More than 5 years have passed since last update.

rubyで文字列 -> Timeをして、現在日時から7日以内かどうか確かめる

Last updated at Posted at 2015-01-18
$ pry
[1] pry(main)> require 'active_support'
=> true
[2] pry(main)> require 'active_support/core_ext'
=> true
[3] pry(main)> str = '2015-01-01 00:00:00 +0900'
=> "2015-01-01 00:00:00 +0900"
[4] pry(main)> now = Time.now.in_time_zone('Asia/Tokyo')
=> Sun, 18 Jan 2015 17:13:35 JST +09:00
[5] pry(main)> (now - Time.parse(str)) <= 7.days

参考

1
1
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
1
1