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

ISO 8601 Date Format For Microformats

  • submit to reddit
        Strftime to get the ISO 8601 (see RFC 3339) full date format for an hEvent Microformat. Doubtless usable in other situations.


If you're in Ruby, you can access this the quick way with:

$ irb
>> require 'time'
=> true
=> "2008-07-09T16:13:30+12:00"

Rails example:

<abbr class="dtstart" title="<%= event.start_date.iso8601"><%= event.start_date.to_s(:long) %></abbr>


Snippets Manager replied on Mon, 2008/12/01 - 3:23pm

Ruby may have a built-in method for this, but it saved me some time in an environment where I don't have direct access to Ruby (specifically, Radiant CMS tags). So thanks!

Snippets Manager replied on Sun, 2008/01/13 - 3:55am

As always, Ruby to the rescue :) Ah well, I'll leave the strftime format here anyway.

Snippets Manager replied on Thu, 2008/06/12 - 7:31pm

Ruby has a built-in method for this: Time#iso8601