<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: strftime code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 17 May 2008 13:20:27 GMT</pubDate>
    <description>DZone Snippets: strftime code</description>
    <item>
      <title>ISO 8601 date format for microformats</title>
      <link>http://snippets.dzone.com/posts/show/5364</link>
      <description>Used this in Ruby to get the ISO 8601 (see RFC 3339) full date format for an hEvent Microformat. Doubtless usable in other situations.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;strftime('%Y-%m-%dT%H:%M:%S%z')&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;How to use:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;abbr class="dtstart" title="&lt;%= event.start_date.strftime('%Y-%m-%dT%H:%M:%S%z') %&gt;"&gt;&lt;%= event.start_date.to_s(:long) %&gt;&lt;/abbr&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 15 Apr 2008 05:03:22 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5364</guid>
      <author>Aupajo (Pete)</author>
    </item>
    <item>
      <title>Ruby strftime without leading zeros</title>
      <link>http://snippets.dzone.com/posts/show/2952</link>
      <description>&lt;code&gt;&lt;br /&gt;Date.today.strftime('%b %d, %Y').gsub(/ 0(\d\D)/, ' \1')&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Um... strike that. Seems %e does it without the extra work. Thanks Peter!</description>
      <pubDate>Thu, 02 Nov 2006 09:49:47 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2952</guid>
      <author>timmorgan (Tim Morgan)</author>
    </item>
    <item>
      <title>Formatting time</title>
      <link>http://snippets.dzone.com/posts/show/1643</link>
      <description>&lt;code&gt;&lt;br /&gt;&gt;&gt;&gt; from e32db import format_time&lt;br /&gt;&gt;&gt;&gt; from time import *&lt;br /&gt;&gt;&gt;&gt; t = time()&lt;br /&gt;&gt;&gt;&gt;&lt;br /&gt;&gt;&gt;&gt; format_time(t)   # for Symbian SQL&lt;br /&gt;u'06/03/2006 23:26:35'&lt;br /&gt;&gt;&gt;&gt; strftime('%d/%m/%Y %H:%M:%S')  # like above&lt;br /&gt;'06/03/2006 23:26:39'&lt;br /&gt;&gt;&gt;&gt; ctime()&lt;br /&gt;'Mon Mar 06 23:26:49 2006'&lt;br /&gt;&gt;&gt;&gt; strftime("%a, %d %b %Y %H:%M:%S +0000")  # email RFC&lt;br /&gt;'Mon, 06 Mar 2006 23:26:59 +0000'&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Here's the (shortened) table for strftime.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;%a  weekday name.  &lt;br /&gt;%A  weekday name (full).  &lt;br /&gt;%b  month name.  &lt;br /&gt;%B  month name (full).  &lt;br /&gt;%c  date and time (locale)&lt;br /&gt;%d  day of month [01,31].  &lt;br /&gt;%H  hour [00,23].  &lt;br /&gt;%I  hour [01,12].  &lt;br /&gt;%j  day of year [001,366].  &lt;br /&gt;%m  month [01,12].  &lt;br /&gt;%M  minute [00,59].  &lt;br /&gt;%p  AM or PM&lt;br /&gt;%S  Second [00,61]&lt;br /&gt;%U  week of year (Sunday)[00,53].&lt;br /&gt; w  weekday [0(Sunday),6].&lt;br /&gt; W  week of year (Monday)[00,53].&lt;br /&gt; x  date (locale).&lt;br /&gt;%X  time (locale).&lt;br /&gt;%y  year [00,99].&lt;br /&gt;%Y  year [2000].&lt;br /&gt;%Z  timezone name.  &lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 06 Mar 2006 21:51:42 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1643</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
    <item>
      <title>RFC-822 compatible dates in RSS feeds</title>
      <link>http://snippets.dzone.com/posts/show/450</link>
      <description>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:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;xml.pubDate(p.updated_at.strftime("%a, %d %b %Y %H:%M:%S %z"))&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;If you're just using strftime someplace else, perhaps in PHP, try:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;strftime("%a, %d %b %Y %H:%M:%S %z")&lt;/code&gt;</description>
      <pubDate>Mon, 04 Jul 2005 03:22:02 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/450</guid>
      <author>peter (Peter Cooperx)</author>
    </item>
  </channel>
</rss>
