The elastic constant of a spring is the force per unit extension.
Think of it as a measure of how "strong" the spring is; the number of
Newtons force needed to stretch the spring by, say 1cm. 

Therefore the elastic constant, k is given by 


The diagram below shows a mass hanging on a spring, initially at its equilibrium
position, being pulled down to cause an extra extension, x. 




When the mass is displaced downwards (as shown above) the restoring
force acting on it, F, is of magnitude kx, upwards. 
If it is displaced upwards the net force is downwards.
Therefore, to describe this situation we write 

so that the equation describes a force with is always in the opposite sense
to the displacement. 

If the mass is released after having been given a displacement, x, then its
initial acceleration will be 




So (as we might have guessed!) the motion
is s.h.m. because the acceleration is directly proportional to x and always
directed in the opposite sense to x. 
By comparison with the basic s.h.m. equation 

we see that, in the case of a mass on a spring, the constant relating
acceleration to displacement, w^{2}
is given by 

and, remembering that 

we can see that the time period of this massspring oscillator is given by 


We are assuming here that the displacement of the mass is small enough for
the spring to behave perfectly elastically. 

For another example of s.h.m., see The Simple Pendulum 