Use: to_formatted_s(format = :default)
for example commentDate.to_formatted_s(:db)
As per Rails docs:
to_formatted_s(format = :default)
Convert to a formatted string - see DATE_FORMATS for predefined
formats. You can also add your own formats to the DATE_FORMATS
constant and use them with this method.
This method is also aliased as to_s.
Examples:
date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
date.to_formatted_s(:db) # => "2007-11-10"
date.to_s(:db) # => "2007-11-10"
date.to_formatted_s(:short) # => "10 Nov"
date.to_formatted_s(:long) # => "November 10, 2007"
date.to_formatted_s(:long_ordinal) # => "November 10th, 2007"
date.to_formatted_s(:rfc822) # => "10 Nov 2007"
-Al
On Apr 9, 12:54 pm, Barak Iqbal
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> hi all,
>
> in my rails application.. i am displaying the dtae time.. which is
> coming from the database which property is timestamp.. so in my view the
> time is displaying as " Wed Apr 09 16:12:52 +0530 2008 ".. but
that in
> not which i was actually.. i need to display only themonth, date and
> time.. thats it.. just like " Apr 09 16:12 " this.. how to get
the time
> like this and display.. can any one fine\d me a solution for this
> aswell..
>
> thankyou.
>
> with regards,
> barak
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---