An optical sensor (1, 21, 31) comprising: a substrate; at least three light emitting elements (3, 4, 5) mounted on a surface of the substrate; a light emission controller configured to control light emission operations of the at least three light emitting elements (3, 4, 5); and at least one light receiving element (6, 32, 33, 34) mounted on the surface of the substrate, wherein light obtained by reflecting, by a detection object (Obj), light emitted from the light emitting elements (3, 4, 5) is received by the light receiving element (6, 32, 33, 34), thereby detecting presence and movement of the detection object (Obj), and the optical sensor (1, 21, 31) includes: a reflected light signal obtaining unit (13, 14) configured to obtain three reflected light signals corresponding to the light from the three light emitting elements (3, 4, 5), on the basis of a light detection signal outputted from the light receiving element (6, 32, 33, 34) when the light obtained by reflecting, by the detection object (Obj), the light from the at least three light emitting elements (3, 4, 5) is received by the light receiving element (6, 32, 33, 34); characterised in that the optical sensor (1, 21, 31) includes: a phase difference calculator configured to obtain a phase difference on the basis of differences or correlations among entire waveforms of a first signal and a second signal of the three reflected light signals (Sr1, Sr2, Sr3) and a phase difference on the basis of differences or correlations among entire waveforms of said second signal and the third signal of the three reflected light signals (Sr1, Sr2, Sr3); and a movement direction identifying unit configured to identify a movement direction of the detection object (Obj) on the basis of at least the two phase differences (T21, T32), wherein when calculating a phase difference between two reflected light signals (Sr1, Sr2, Sr3), the phase difference calculator sums, in a state where one of the reflected light signals (Sr1, Sr2, Sr3) is temporally shifted by a predetermined shift amount, a square of a difference from the other of the reflected light signals (Sr1, Sr2, Sr3) over the entire waveform for a plurality of shift amounts, and sets a shift amount (x21, x32) with which the summed value is minimum, as the phase difference. a substrate; at least three light emitting elements (3, 4, 5) mounted on a surface of the substrate; a light emission controller configured to control light emission operations of the at least three light emitting elements (3, 4, 5); and at least one light receiving element (6, 32, 33, 34) mounted on the surface of the substrate, wherein light obtained by reflecting, by a detection object (Obj), light emitted from the light emitting elements (3, 4, 5) is received by the light receiving element (6, 32, 33, 34), thereby detecting presence and movement of the detection object (Obj), and the optical sensor (1, 21, 31) includes: a reflected light signal obtaining unit (13, 14) configured to obtain three reflected light signals corresponding to the light from the three light emitting elements (3, 4, 5), on the basis of a light detection signal outputted from the light receiving element (6, 32, 33, 34) when the light obtained by reflecting, by the detection object (Obj), the light from the at least three light emitting elements (3, 4, 5) is received by the light receiving element (6, 32, 33, 34); a reflected light signal obtaining unit (13, 14) configured to obtain three reflected light signals corresponding to the light from the three light emitting elements (3, 4, 5), on the basis of a light detection signal outputted from the light receiving element (6, 32, 33, 34) when the light obtained by reflecting, by the detection object (Obj), the light from the at least three light emitting elements (3, 4, 5) is received by the light receiving element (6, 32, 33, 34); characterised in that the optical sensor (1, 21, 31) includes: a phase difference calculator configured to obtain a phase difference on the basis of differences or correlations among entire waveforms of a first signal and a second signal of the three reflected light signals (Sr1, Sr2, Sr3) and a phase difference on the basis of differences or correlations among entire waveforms of said second signal and the third signal of the three reflected light signals (Sr1, Sr2, Sr3); and a movement direction identifying unit configured to identify a movement direction of the detection object (Obj) on the basis of at least the two phase differences (T21, T32), a phase difference calculator configured to obtain a phase difference on the basis of differences or correlations among entire waveforms of a first signal and a second signal of the three reflected light signals (Sr1, Sr2, Sr3) and a phase difference on the basis of differences or correlations among entire waveforms of said second signal and the third signal of the three reflected light signals (Sr1, Sr2, Sr3); and a movement direction identifying unit configured to identify a movement direction of the detection object (Obj) on the basis of at least the two phase differences (T21, T32), wherein when calculating a phase difference between two reflected light signals (Sr1, Sr2, Sr3), the phase difference calculator sums, in a state where one of the reflected light signals (Sr1, Sr2, Sr3) is temporally shifted by a predetermined shift amount, a square of a difference from the other of the reflected light signals (Sr1, Sr2, Sr3) over the entire waveform for a plurality of shift amounts, and sets a shift amount (x21, x32) with which the summed value is minimum, as the phase difference.