Without going through what the tutorial suggested, you can simply create a helper method and put it in your Helper folder. call this helper method in your views. Here is an example.
use the strftime method.
def date_format(date) date.strftime("%d/%m/%Y %I:%M %p") end
I tested it in irb .
>> require 'date' => true >> d = DateTime.now => #<DateTime: 2014-05-26T18:54:59-05:00 ((2456804j,86099s,806097708n),-18000s,2299161j)> >> def date_format(date) >> date.strftime("%d/%m/%Y %I:%M %p") >> end => nil >> date_format(d) => "26/05/2014 06:54 PM" >>
Wally ali
source share