Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails convert updated_at to rfc3339 format

I'm trying to convert the standard rails DB fields created_at and updated_at into the atom feed rfc3339 format. So far I have tried:

DateTime.rfc3339(issue.updated_at)

and

DateTime.parse(issue.updated_at).rfc3339

and both times I get:

no implicit conversion of ActiveSupport::TimeWithZone into String

If I try and validate my atom feed at w3.org I get the following message:

updated must be an RFC-3339 date-time: 2013-06-27 13:42:34 UTC

The above error is for all the database updated_at fields. When I create the feed updated at field like the following I get no error:

xml.updated(Time.now.xmlschema)

I've searched high and low without fixing this issue. I did find Convert db date to rfc3339 but that didn't work for me.

Any ideas?

like image 502
Nicholas John Martin Avatar asked Jul 02 '13 15:07

Nicholas John Martin


1 Answers

Try:

issue.updated_at.to_datetime.rfc3339
like image 103
GoGoCarl Avatar answered Nov 12 '22 10:11

GoGoCarl