You could just do it (replace Time
with DateTime
if using direct Ruby - i.e. Rails):
DateTime.now.strftime('%m/%d/%Y')
If you use this format a lot, you may need to create a date_time_formats
initializer in your RAILS_ROOT/config/initializers
folder (assuming Rails 2), something like this:
# File: date_time_formats.rb ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!( :human => "%m/%d/%Y" )
Which allows you to use a more friendly version of DateTime.now.to_s(:human)
in your code.
jerhinesmith Sep 09 '10 at 14:57 2010-09-09 14:57
source share