
function getCurrentTime (){
	// Get the current datetime
	var currentTime = new Date();
	
	// Get the hour portion of the current time
	var currentHour = currentTime.getHours();
	
	// Determine AM or PM
	var AMorPM = "AM";
	if (currentHour > 11){
		AMorPM ="PM";
		if (currentHour > 12){
			currentHour = currentHour - 12;
		}
	}
	
	// Show midnight as "12" instead of "0" 
	if (currentHour === 0){
		currentHour = 12;
	} 
	
	// Get the current minute of the current time
	var currentMinute = currentTime.getMinutes();
	
	// If the minute value is less than 10 pad it with a leading '0' character
	if (currentMinute < 10){
		currentMinute = "0" + currentMinute;
	}
	
	// Get the current second of the current time
	var currentSecond = currentTime.getSeconds();
	
	// If the second value is less than 10 pad it with a leading '0' character
	if (currentSecond < 10){
		currentSecond = "0" + currentSecond;
	}

	// create a string for the time display
	var timeString = currentHour + ":" + currentMinute + ":" + currentSecond + " " + AMorPM;
	
	// Set the value of the time display
	document.getElementById("timeDisplay").innerHTML = timeString;
	
	// Repeat function in one second
	setTimeout(getCurrentTime, 1000);
  }

