Reputation: 815
@object.updated_at.localtime displays "2015-04-20 14:39:27 -0700". I don't want to display the -0700, is there a method that will strip out the timezone for display purposes?
Upvotes: 4
Views: 10246
Reputation: 2946
If you plan to use that format across your app, you might as well create a new time format:
# config/initializers/time_formats.rb
Time::DATE_FORMATS[:no_timezone] = "%Y-%m-%d %H:%M:%S"
Then just use it like this:
Time.now.to_s(:no_timezone)
Upvotes: 6
Reputation: 1931
You should use I18n.l
and define a format in. your language.yml
I18n.l @object.updated_at, format: :my_format
en:
time:
formats:
myformat: "%Y-%m-%d %H:%M"
Upvotes: 3