Reputation: 1123
I am requesting a list of objects from Salesforce via the Restforce API in my Rails 4 application. When I request the date and time field on each object, I receive in in iso8601 format. For example, in my view, the date and time are displayed like this:
2014-10-03T22:37:15.000+0000
In my view I have:
<td><%= transaction.Recorded_On__c %></td>
I would like to be able to somehow call strftime on Recorded_On__c however, I get a undefined method error when I do that currently. I've also tried date_select(transaction.Recorded_On__c) and receive syntax errors. In the end I would like to have the date displayed as month("Feb"), day("20"), year("2014)".
Upvotes: 0
Views: 1179
Reputation: 2558
First you need to convert string to date or time and then - use I18n.l method to specify needed format.
<td><%= I18n.l "2014-10-04T22:49:02+04:00".to_time, format: "%b.%d.%Y" %></td>
Upvotes: 1
Reputation: 1137
You can use I18n, you have to create en.yml that you can find here:
<td><%= l transaction.Recorded_On__c.to_date, format: :long %></td>
Upvotes: 1