Dopamine serves many functions, and dopamine neurons are correspondingly diverse. We use a combination of optogenetics, behavioral experiments, and high-resolution videotracking to probe for the functional capacities of two single, identified dopamine neurons in larval Drosophila. The DAN-f1 and the DAN-d1 neuron were recently found to carry aversive teaching signals during Pavlovian olfactory learning. We enquire into a fundamental feature of these teaching signals, namely their temporal "fingerprint". That is, receiving punishment feels bad, whereas being relieved from it feels good, and animals and humans alike learn with opposite valence about the occurrence and the termination of punishment (the same principle applies in the appetitive domain, with opposite sign). We find that DAN-f1 but not DAN-d1 can mediate such timing-dependent valence reversal: presenting an odor before DAN-f1 activation leads to learned avoidance of the odor (punishment memory), whereas presenting the odor upon termination of DAN-f1 activation leads to learned approach (relief memory). In contrast, DAN-d1 confers punishment memory only. These effects are further characterized in terms of the impact of the duration of optogenetic activation, the temporal stability of the memories thus established, and the specific microbehavioral patterns of locomotion through which they are expressed. Together with recent findings in the appetitive domain and from adult Drosophila, our results suggest that heterogeneity in the temporal fingerprint of teaching signals might be a more general principle of reinforcement processing through dopamine neurons.