This ability of plants to respond to the photoperiod is controlled by a light-sensitive pigment called phytochrome, which is present in the leaves and exists in two different forms, R(red)/P(r) (inactive form) and P(far-red)/P(fr) (active form), which can change from one to the other. P(red) absorbs red light and is converted to P(far-red), while P(far-red) absorbs far-red light and is converted to P(red). As sunlight contains more red light than far-red light, during the day P(red) converts to P(far-red), while during the night the unstable p(far-red) slowly reverts back to P(red).
If the day is long enough, P(far-red) accumulates and long-day plants flower.
If the night is long enough, P(red) accumulates and short-day plants flower.