2014-10-28

Rails 4+ Date & Time custom format , include inspect

just code , add in config/initialize
Time::DATE_FORMATS[:default] = "%Y-%m-%d %H:%M:%S %z"
Date::DATE_FORMATS[:default] = "%Y-%m-%d %H:%M:%S %z"

class ActiveSupport::TimeWithZone
  def inspect
    "#{time.strftime("%Y-%m-%d %H:%M:%S")} #{formatted_offset}"
  end
end

沒有留言:

張貼留言