Phase reversal of the diurnal cycle in the midlatitude ionosphere