Using your own date and time formats
Here is an easy way to implement your own date and time formats without repeatedly convert dates with ugly converts or helper methods.
In your environment.rb file, you can define your own time formats like this:
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!( :client_readable => "%A %B %d at %H:%M", # => Friday April 25 at 11:10 :client_reports => "%d/%m/%Y at %H:%M" # => 25/04/2008 at 11:10 )
And then you can use this formatting in your views really easy:
Last updated on <%= @post.updated_at.to_s(:client_readable) %> # => "Last updated on Friday April 25 at 11:20"
Source: workswithruby.com/2008/4/5-rails-tips
5 Comments
Jånne
Dude, your comment system is so awesome :D
Xavier
Sweet work man, gotta change your capture on the portfolio page though...
Ra1der
Wonderful design frex <3 :)
fodoia
looks great
Jånne
tästing jårr ahj-akkz