how to convert Date to this json format

Hi    I have to create a json date like

{"startDate":"\/Date(1291145744713-0700)\/","endDate":"\/Date(1293824144713-0700)\/"}

        This is just an example. My case startdate = Time.now-2.day          enddate = Time.now

      I dont know how to convert this to the above format. Please help

Thanks

date_range = {:start_date => (Time.now - 2.days).to_i, :end_date => Time.now.to_i}

date_range.to_json will give {\"start_date\":1314182763,\"end_date\":1314355563}

Is this what you want?

t = Time.now puts t.strftime("%s%z")

format = '{"startDate":"\/Date(%s)\/"}' puts format % [t.strftime("%s%z")]

--output:-- 1314356117-0400 {"startDate":"\/Date(1314356117-0400)\/"}