Finnnn Finnnn - 1 year ago 42
Ruby Question

How do I get day of the week in from a date object?

I have a date object in Rails, which I'd like to format.

I've made it this far

delivery_time.date.strftime("%w, %d/%m/%Y")


I'd like it to print out 'Wednesday, 04/01/2012'

Is there a quick method to change the '%w' into 'Wednesday'?

Answer Source

Looking at the Ruby docs for strftime

Time.now.strftime("%A, %d/%m/%Y")
=> "Wednesday, 04/01/2012"

The %A character is the full day name.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download