The physics
Long bodies need two things: the relative speed and the right distance.
same way: vrel = v₁ − v₂ opposite ways: vrel = v₁ + v₂
A person is a single point. A train passes a person in t = L / vrel.
Two trains must slide past each other by both lengths.
t = (L₁ + L₂) / vrel bridge or tunnel: t = (L + ℓ) / v
A train that speeds up still travels its own length. For its time, use L = ut + ½at².
Change km/h to m/s: multiply by 5/18.