it depends on cases. but I can give you the general way
first you should find the relationship between the acceleration of oscillator and its displacement
Then, by means of Newton's second law, F=ma
find the a in terms of x if a is directly proportional to minus x
then, for S.H.M a = -w^2x , where w is the angular frequency of motion
w = =2pi/T
T=2pi/w
Related Threads for: Derivation of an S.H.M. Equation