Here is the quick code to get the current time in 12 hours format using JavaScript.
1: <script language="javascript">
2: function getTime() {
3: var dTime = new Date();
4: var hours = dTime.getHours();
5: var minute = dTime.getMinutes();
6: var period = "AM";
7: if (hours > 12) {
8: period = "PM"
9: }
10: else {
11: period = "AM";
12: }
13: hours = ((hours > 12) ? hours - 12 : hours)
14: return hours + ":" + minute + " " + period
15: }
16: </script>