T violation in neutrino oscillations in vacuum is a well known fact. Due to the CPT theorem this fact is strictly connected with the CP violating phase in the neutrino mixing matrix. Since neutrino interaction with matter or external electromagnetic field violates Lorentz invariance, influence of external conditions can lead to T violation even in the model with real mixing matrix, e.g. in the two-flavor model. We study neutrino propagation in dense matter and electromagnetic field taking into account both neutrino oscillations and spin rotation. We obtain a sufficient condition of T violation in the general case. In the two-flavor model we derive neutrino spin-flavor transition probabilities and discover a T-violating term, which arises due to simultaneous influence of electromagnetic field and moving matter.