Rails将updated_at转换为rfc3339格式



我正在尝试将标准rails DB字段created_at和updated_at转换为atom提要rfc3339格式。到目前为止,我已经尝试过:

DateTime.rfc3339(issue.updated_at)

DateTime.parse(issue.updated_at).rfc3339

两次我都得到:

no implicit conversion of ActiveSupport::TimeWithZone into String

如果我尝试在w3.org上验证我的atom提要,我会收到以下消息:

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

以上错误适用于所有数据库updated_at字段。当我创建在如下字段更新的提要时,我没有得到错误:

xml.updated(Time.now.xmlschema)

我到处找都没有解决这个问题。我确实找到了将数据库日期转换为rfc3339,但这对我不起作用。

有什么想法吗?

尝试:

issue.updated_at.to_datetime.rfc3339

最新更新