Dave Newman

3 notes &

Rails json date format

The default rails json date format doesn’t parse in javascript. You should be able to tell ActiveSupport to not use the standard one like so:

config.active_support.use_standard_json_time_format = false

but I couldn’t get that to work so I duck punched the DateTime class like so:

class DateTime
    def as_json(options = nil)
        strftime('%Y-%m-%d %H:%M:%S')
    end
end

That worked

  1. whatupdave posted this