Forum: Ruby on Rails custom date/time formats?

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.
cool_screen_name90001 (Guest)
on 2005-11-12 12:49
(Received via mailing list)
I can't figure out how to format variables to custom
date/time formats. In a template, I have:

item.added.to_formatted_s(:format=>"%Y")

and rather than the year, it outputs:

Mon Oct 31 20:14:14 MST 2005


Thanks for any help!
CSN




__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
technoweenie (Guest)
on 2005-11-12 12:49
(Received via mailing list)
On 11/7/05, CSN <cool_screen_name90001@yahoo.com> wrote:
> I can't figure out how to format variables to custom
> date/time formats. In a template, I have:
>
> item.added.to_formatted_s(:format=>"%Y")
>
> and rather than the year, it outputs:
>
> Mon Oct 31 20:14:14 MST 2005

http://rails.rubyonrails.com/classes/ActiveSupport...

ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update(:format
=> '%Y')

item.added.to_s(:format)


--
rick
http://techno-weenie.net
This topic is locked and can not be replied to.