title: Format DateTime in Text Box in Rails
body: <p>Is there an easy way to format the display of a <code>DateTime</code> value in a Rails view?</p>
  
  <p>For example, if I'm doing something like:</p>
  
  <pre><code>&lt;%= text_field :my_object, :start_date %&gt;
  </code></pre>
  
  <p>and only want to display the Date part of the <code>:start_date</code> (i.e. I want to hide the time part), is there a way to format the <code>:start_date</code> string inside of the view such that it will work for creating new <code>my_object</code> items and updating new <code>my_object</code> items?</p>
  
  <p>Just a clarification:</p>
  
  <p>Doing</p>
  
  <pre><code>&lt;%= text_field 
         :my_object,
         :start_date,
         :value =&gt; @my_object.start_date.strftime('%m/%d/%Y') %&gt;
  </code></pre>
  
  <p>works <em>beautifully</em> when the object already exists (i.e. on item updates), however, when creating a <strong>new</strong> item, since start_date will initially be nil, the view will throw an error</p>
  
  <pre><code>while evaluating nil.strftime
  </code></pre>