Rails 3 Finding day of week

You can also get the string, like "Wednesday", using time.strftime("%A")


Can't you use time.wday, 0 = sunday and so on


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')

If you're attempting to write your own calendar from scratch and want to write a function to do day lookup, you might want to check out Conway's Doomsday Algorithm, which is an interesting method for determining the day of the week on any given date. Otherwise the standard time class has a wday method which returns a number from 0-6 (0 is Sunday, 1 is Monday, etc).