Forum: Rails I18n DateFields and ActiveRecords

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cc24d46043aac77ee0cba0ad2c2d51f1?d=identicon&s=25 Jonas (Guest)
on 2007-07-01 13:36
Here is some typical code, right?

<% for column in User.visible_columns true %>
<tr>
  <th><%= column.human_name %></th>
  <td><%=h @user.send(column.name) %></td>
</tr>
<% end %>

I want to customize how the date is formatted for timestamps. How do I
do that? (I want the code above to automatically use my new format for
timestamp/datetime columns)
C1ddce6691ca0631671c243fa038cbbd?d=identicon&s=25 Moises Deniz (railsgeek)
on 2007-07-02 13:52
>
> <% for column in User.visible_columns true %>
> <tr>
>   <th><%= column.human_name %></th>
>   <td><%=h @user.send(column.name) %></td>
> </tr>
> <% end %>
>
> I want to customize how the date is formatted for timestamps. How do I
> do that? (I want the code above to automatically use my new format for
> timestamp/datetime columns)

Try modifing the DATE_FORMATS[:db] constant with your own format...

you can see at:
http://api.rubyonrails.org/classes/ActiveSupport/C...
This topic is locked and can not be replied to.