Rails 3 Finding day of week

前端 未结 5 1603
旧巷少年郎
旧巷少年郎 2020-12-08 13:13

I\'m trying to make my own calendar because i cant seem to get any help with event calendar so what im trying to do is Display the day of the week ie.. January 1 2011 is a S

5条回答
  •  执念已碎
    2020-12-08 13:36

    Actively using in Rails 4 - should in most other versions as well...

    Both of these options will give you the day string (eg. "Saturday") for the date specified:

    Specific date:

    Date.new(2011, 1, 1).strftime('%A') # returns "Saturday"
    

    Today:

    Date.today.strftime('%A')
    

提交回复
热议问题