rails dates with json

前端 未结 7 1629
你的背包
你的背包 2020-11-30 02:16

I am implementing a Facebook application and using AJAX/JSON.

However the JSON structures that are returned have this format 2010-05

7条回答
  •  被撕碎了的回忆
    2020-11-30 02:34

    With timezone working in all major browsers and ie7+:

    class ActiveSupport::TimeWithZone
      def as_json(options = {})
        strftime('%Y/%m/%d %H:%M:%S %z')
      end
    end
    

提交回复
热议问题