ubuntu server time

I have a ubuntu server on aws, and when I do new Date().getTime() on the server the time seems a bit off (a couple of minutes).

How do I get it to be more accurate.

sudo apt-get install ntp

See the docs for more information.