There is no need to apply anything. Just add this code at the end of the variable to which the date is assigned. for example
@todaydate = "2011-05-19 10:30:14" @todaytime.to_time.strftime('%a %b %d %H:%M:%S %Z %Y')
You will receive the correct format as you wish. You can check it in the Rails console
Loading development environment (Rails 3.0.4) ruby-1.9.2-p136 :001 > todaytime = "2011-05-19 10:30:14" => "2011-05-19 10:30:14" ruby-1.9.2-p136 :002 > todaytime => "2011-05-19 10:30:14" ruby-1.9.2-p136 :003 > todaytime.to_time => 2011-05-19 10:30:14 UTC ruby-1.9.2-p136 :008 > todaytime.to_time.strftime('%a %b %d %H:%M:%S %Z %Y') => "Thu May 19 10:30:14 UTC 2011"
Try "date_format" to display the date in a different format.
All the best!!!
Rubyist May 20 '11 at 11:25 2011-05-20 11:25
source share