Which rates should we use to discount costs and benefits of different natures at different time horizons? We answer this question by considering a representative agent consuming two goods whose availability evolves over time in a stochastic way. We extend the Ramsey rule by taking into account the degree of substitutability between the two goods and of the uncertainty surrounding the economic and environmental growths. The rate at which environmental impacts should be discounted is in general different from the one at which monetary benefits should be discounted. We provide arguments in favor of an ecological discount rate smaller than the economic discount rate. In particular, we show that, under certainty and Cobb-Douglas preferences, the difference between the economic and the ecological discount rates equals the difference between the economic and the ecological growth rates. Using data about the link between biodiversity and economic development, I estimate that the rate at which changes in biodiversity should be discounted is 1.5%, whereas changes in consumption should be discounted at 3.2%.