Skip to content

Instantly share code, notes, and snippets.

@awesome
Created February 10, 2010 21:26
Show Gist options
  • Save awesome/300862 to your computer and use it in GitHub Desktop.
Save awesome/300862 to your computer and use it in GitHub Desktop.
http://snippets.dzone.com/posts/show/5364
Strftime to get the ISO 8601 (see RFC 3339) full date format for an hEvent Microformat. Doubtless usable in other situations.
strftime('%Y-%m-%dT%H:%M:%S%z');
If you're in Ruby, you can access this the quick way with:
$ irb
>> require 'time'
=> true
>> Time.now.iso8601
=> "2008-07-09T16:13:30+12:00"
Rails example:
<abbr class="dtstart" title="<%= event.start_date.iso8601"><%= event.start_date.to_s(:long) %></abbr>
aslak.hellesoy posts on Jun 12, 2008 at 19:58
Ruby has a built-in method for this: Time#iso8601
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment