<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>mehblog: Formatting dates in rails templates using strftime()</title>
    <link>http://blog.pauldalton.co.uk/articles/2005/08/23/formatting-dates-in-rails-templates-using-strftime</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>random mumblings</description>
    <item>
      <title>Formatting dates in rails templates using strftime()</title>
      <description>&lt;p&gt;Recently I needed to be able to format a date that I had retrieved from the database into something more readable. In smarty one would do something like &lt;code&gt;$date|date_format&lt;/code&gt; but I could not find anything like that in ruby.&lt;/p&gt;


	&lt;p&gt;Then someone pointed out that the date field in the database would be recognised as such and would be a date object in my View.&lt;/p&gt;


	&lt;p&gt;As the date is a Date object I can use &lt;a href="http://www.ruby-doc.org/core/classes/Time.html#M000236"&gt;strftime()&lt;/a&gt; to reformat the date any way I want to. 
eg. &lt;code&gt;@event.start_date.strftime("%d %B %Y")&lt;/code&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 23 Aug 2005 15:07:38 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:adbd7922ccc8f7d929b7044f3aba3609</guid>
      <author>paul</author>
      <link>http://blog.pauldalton.co.uk/articles/2005/08/23/formatting-dates-in-rails-templates-using-strftime</link>
      <category>Rails</category>
    </item>
  </channel>
</rss>
