views:

36

answers:

1
>> events.first.datetime
=> Wed Sep 15 19:00:00 -0400 2010
>> Time.parse(events.first.datetime)
NoMethodError: private method `gsub!' called for Wed Sep 15 19:00:00 -0400 2010:Time
+5  A: 

Time#parse creates a Time object out of a String, which it takes as its first argument. You already have a Time object, so Time.parse doesn't know what to do with it.

In order to format the date like you want it, take a look at Time#strftime. You can format it like you want with the format string:

events.first.datetime.strftime("%A %B %d, %Y at %I:%M %p")

Take a look at the manual entry for strftime for other format specifiers.

Daniel Vandersluis
i need to format it better like "Wednesday September 15, 2010 at 7:00pm"
Matt