DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

RFC-822 Compatible Dates In RSS Feeds

07.03.2005
| 9793 views |
  • submit to reddit
        If you're building RSS 2.0 files with .rxml files on your Rails app, this sort of line will get you a valid date/time:

xml.pubDate(p.updated_at.strftime("%a, %d %b %Y %H:%M:%S %z"))

If you're just using strftime someplace else, perhaps in PHP, try:

strftime("%a, %d %b %Y %H:%M:%S %z")
    

Comments

Snippets Manager replied on Mon, 2012/05/07 - 2:13pm

You can also send this message directly to a Time instance: p.updated_at.rfc2822

Snippets Manager replied on Mon, 2012/05/07 - 2:13pm

Nice!

Snippets Manager replied on Mon, 2012/05/07 - 2:13pm

Guess what? The ruby Time class has a class method for this already: Time.rfc2822(p.updated_at)