1 nautical mile is about 1.85 km. So, 4 (km)/1.85 (km/NM)= 2.16 NM. They are about 2.16 NM apart at the initial visual contact.
Knots is NM/h. Thus, they will collide in 2.16 (NM) / 280 (NM/h) hours, which is 0.0077 hours. Therefore, 0.0077*3600 = 27.8 seconds.