views:

61

answers:

1

so I have to insert a bunch of records from a data source that has dates in the format Sun, Sep 13 1:00 PM.

I'm just going to execute SQL that uses STR_TO_DATE

But I was wondering in case I need it in the future if you guys know of a way to do this using a ruby method...like a reverse strftime

+1  A: 

Yes, look at Datetime.strptime and the nearby Datetime.parse (similar methods for Date).

Pretty much any language that uses the C strftime will have strptime as well.

Kathy Van Stone
hmmmmmm i thought i looked through the Date and Time ruby functions but i guess i should be more thorough and less stack overflow trigger happy. thanks anyway though!
Neil Sarkar
It helped that I knew what to look for -- I went straight to strptime. Note that it is a class method, not an instance method.
Kathy Van Stone