Given that $a=\dfrac{d^2x}{dt^2}=-\dfrac{k}{m}x$
Let $\frac{k}{m}=\omega^2$. Here $\omega$ is the angular frequency.
$$a=-\omega^2 x \implies \frac{dv}{dt}=-\omega^2x \implies \dfrac{dv}{dx} \cdot \dfrac{dx}{dt}=-\omega^2x \implies \int_{0}^{v} v \cdot dv=\int_{A}^{x}-\omega^2 x \cdot dx \\ \implies v= \pm \omega \cdot \sqrt{A^2-x^2}$$
Where $A$ is amplitude or the maximum displacement of the block or object from the initial position.
$$\dfrac{dx}{dt}=\pm \omega \sqrt{A^2-x^2} \implies \dfrac{dx}{\sqrt{A^2-x^2}}=\pm \omega \cdot dt$$
The rest is trivial. The above integral is a standard one. Or you can solve it using the substitution $x=A \sin u$