Reputation: 2361
I have a form that collects datetime as follows: 2013-05-21 00:00:00 UTC
This needs to be converted to a XML compatible format. I tried using the .rfc3339
method:
DateTime.rfc3339('2013-05-21 00:00:00 UTC')
I get the following error: convert ActiveSupport::TimeWithZone to String
Any suggestions?
Upvotes: 0
Views: 1099
Reputation: 6672
The DateTime::rfc3339
class method parses an RFC3339 string and returns a date object. To convert a date object into an RFC3339 string, use the following code:
DateTime.parse('2013-05-21 00:00:00 UTC').rfc3339
Upvotes: 2