̃Gg[͂ĂȃubN}[Nɒlj

Ruby :: イディオム / 今日、昨日、一ヶ月前



require 'date'
 
# today
today = DateTime.now.strftime('%Y-%m-%d')
 
# yesterday
yesterday = (DateTime.now - 1).strftime('%Y-%m-%d')
 
# 1 month ago
monthago = (DateTime.now << 1).strftime('%Y-%m-%d')
 
# 3 month ago
threemonthago = (DateTime.now << 3).strftime('%Y-%m-%d')



programming/ruby/idiom/today_yesterday_1month_ago.txt