$\newcommand{\d}{\mathrm{d}}$I am having a problem here because acceleration varies with distance, and I am not able to relate it with time
\begin{align} a &=-\frac{kx}{m} \\ v\frac{\d v}{\d x} &= -\frac{kx}{m} \end{align} For $x_{\max}$ \begin{align} 0-v_{0}^2 &= -\frac{kx^2}{m} \\ x &= \sqrt{\frac{mv_0}{k}} \end{align}
But I still can’t find time