Answer
$t = 4.2~hours$
Work Step by Step
We can find the components of ship A's velocity relative to the port:
$v_{Ax} = (24~knots)~cos~45^{\circ} = 17.0~knots$ (west)
$v_{Ay} = (24~knots)~sin~45^{\circ} = 17.0~knots$ (north)
We can find the components of ship B's velocity relative to the port:
$v_{Bx} = (28~knots)~sin~40^{\circ} = 18.0~knots$ (west)
$v_{By} = (28~knots)~cos~40^{\circ} = 21.4~knots$ (south)
We can find the components of the velocity of ship A relative to ship B:
$v_x = 17.0~knots - 18.0~knots = -1.0~knot~ (west) = 1.0~knot~ (east)$
$v_y = 17.0~knots+21.4~knots = 38.4~knots~(north)$
We can find the speed of ship A relative to ship B:
$v = \sqrt{(1.0~knot)^2+(38.4~knot)^2}$
$v = 38.4~knots$
We can find the time when the distance between the ships is 160 nautical miles:
$t = \frac{160}{38.4} = 4.2~hours$