Temperature profoundly affects aging in both poikilotherms and homeotherms. A general belief is that lower temperatures extend lifespan, whereas higher temperatures shorten it. Although this "temperature law" is widely accepted, it has not been extensively tested. Here, we systematically evaluated the role of temperature in lifespan regulation in C. elegans. We found that, although exposure to low temperatures at the adult stage prolongs lifespan, low-temperature treatment at the larval stage surprisingly reduces lifespan. Interestingly, this differential effect of temperature on longevity in larvae and adults is mediated by the same thermosensitive TRP channel TRPA-1 that signals to the transcription factor DAF-16/FOXO. DAF-16/FOXO and TRPA-1 act in larva to shorten lifespan but extend lifespan in adulthood. DAF-16/FOXO differentially regulates gene expression in larva and adult in a temperature-dependent manner. Our results uncover complexity underlying temperature modulation of longevity, demonstrating that temperature differentially regulates lifespan at different stages of life.