Let an observer (2) be positioned on one side of a rod of length l_0 in his rest frame. Let (1) be another observer relative to whom (2) is moving to the left with velocity v. Their initial configuration is shown below in (1)'s frame.
(3)...l...(2)
(1)
the rod is moving leftwards.
Let the length of the rod be l in (1)'s frame.
E_1 : (3) and (1) coincide.
E_2 : (2) and (1) coincide.
According to (1), the time between the two events is \frac{l}{v}, and the distance is zero. Therefore,
t_1^2 - x_1^2 = \frac{l^2}{v^2}
According to (2), the time between the two events is \frac{l_0}{v}, and the distance is l_0. Therefore,
t_2^2 - x_2 ^2 = \frac{l_0^2}{v^2} - l_0^2
Equating the two, we get
l = l_0\sqrt{1-v^2}