Please do not reinvent the wheel. There are many open-source & COTS solutions that already exist to solve this problem.
Please take a look at the following JavaScript libraries:
I wrote a one-liner using Moment.js below. You can check out the demo here: JSFiddle.
moment('2014-08-20 15:30:00').format('MM/DD/YYYY h:mm a'); // 08/20/2014 3:30 pm