Never been to DZone Snippets before?

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

RFC-822 compatible dates in RSS feeds (See related posts)

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 on this post

technoweenie posts on Jul 04, 2005 at 15:35
Guess what? The ruby Time class has a class method for this already:

Time.rfc2822(p.updated_at)
peter posts on Jul 05, 2005 at 19:01
Nice!
horetore posts on Jul 16, 2005 at 01:20
You can also send this message directly to a Time instance:

p.updated_at.rfc2822

You need to create an account or log in to post comments to this site.


Click here to browse all 4858 code snippets

Related Posts