1
我有這樣的控制器:讓RAILS以特定格式返回dateTime?
class SchedulesController "post", :except => :index
def index
#Schedules.create(:id => -1, :deviceId => "2002", :subject => "Test 2", :scheduleTime => Time.new, :repeatEveryYear => "FALSE")
#@schedules = Schedules.all
respond_to do |format|
format.html # list.html.erb
format.json { render :json => @schedules.to_json }
end
end
def create
@schedule = Schedules.new.from_json(params[:schedule])
@schedule.save
render :json => "success"
end
end
附表有日期時間字段,我怎麼能得到控制返回這段時間格式爲 「YYYY-MM-DD HH:MM:ZZZZ」(ZZZZ =具體GMT時區)?
謝謝 瑟倫