How can I calculate the day of the week of a date in ruby?

前端 未结 10 621
抹茶落季
抹茶落季 2020-12-01 05:05

How can I calculate the day of the week of a date in Ruby? For example, October 28 of 2010 is = Thursday

10条回答
  •  无人及你
    2020-12-01 05:44

    basically the same answer as Andreas

    days = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
    today_is = days[Time.now.wday]
    
    if today_is == 'tuesday'
      ## ...
    end
    

提交回复
热议问题