Change general solution form of the simple harmonic oscillator

When I try to solve the simple harmonic oscillator equation

DSolve[y''[x] + k*y[x] == 0, y[x], x]


the solution is given by:

{{y[x] -> C[1] Cos[Sqrt[k] x] + C[2] Sin[Sqrt[k] x]}}


How can I get the general solution in the form

{{y[x] -> C[1] Cos[Sqrt[k] x + C[2]]}}


Just a simple trigonometric simplification.

soly = DSolve[{y''[x] + k y[x] == 0, y[0] == c0 Cos[phi0], y'[0] == c0 Sqrt[k] Sin[phi0]}, y, x][[1]] /. {c0 -> C[1], phi0 -> -C[2]}
yx = y[x] /. soly // TrigReduce

(* C[1] Cos[Sqrt[k] x + C[2]] *)


I cheated a little here.

Btw, I do not think your formula is correct. It should be

(page 167, Differential equations and their applications, 4th edition. By Braun).

Hence, you can do

ClearAll[x,y,k];
sol=y[x]/.First@DSolve[y''[x]+k*y[x]==0,y[x],x];
convert[sol,k,x]


Where

convert[sol_, k_, x_] := Module[{a, b, expr},
expr = TrigExpand[sol];
b = CoefficientList[expr, Cos[Sqrt[k] x], 2][[2]];
a = CoefficientList[expr, Sin[Sqrt[k] x], 2][[2]];
Sqrt[a^2 + b^2] Cos[Sqrt[k] x - ArcTan[b, a]]
]