function updateClock(){
  var currentTime = new Date();
  
  //Get the time in GMT
  var currentHours = currentTime.getUTCHours();
  var currentMinutes = currentTime.getUTCMinutes();
  var currentSeconds = currentTime.getUTCSeconds();
  
  var localHours = currentTime.getHours();
  var localMinutes = currentTime.getMinutes();
  
  var localtime = getFormattedTime(localHours,localMinutes,"LOCAL");
 
  var GMTTime = currentTime.toGMTString();
  var GMTTime = GMTTime.substring(4,GMTTime.length-3) + "GMT";
  // Update the time display
  document.getElementById('clock').innerHTML = "<font face='tahoma' size='2pt'> &nbsp;&nbsp;&nbsp;<font color='#F5F7F6'>" + GMTTime + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + 
  											   "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+
  											   "<font color='#F7D138'>YOUR TIME &nbsp;&nbsp;" + localtime +
  											   "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color='#F7D138'>NEWYORK &nbsp;&nbsp;" + getFormattedTime(currentHours, currentMinutes, 'NY') +
  											   "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color='#F7D138'>LONDON &nbsp;&nbsp;" + getFormattedTime(currentHours, currentMinutes, 'LON') +
  											   "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color='#F7D138'>BARCELONA &nbsp;&nbsp;" + getFormattedTime(currentHours, currentMinutes, 'BAR') +
  											   "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color='#F7D138'>TOKYO &nbsp;&nbsp;" + getFormattedTime(currentHours, currentMinutes, 'TYO') + 
  											   "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color='#F7D138'>SYDNEY &nbsp;&nbsp;" + getFormattedTime(currentHours, currentMinutes, 'SYD');
}

function getFormattedTime(hours, mins, timezone){
	
	if(timezone == "NY"){
		hours = hours-4;
	}else if(timezone == "LON"){
		hours = hours+1;
	}else if(timezone == "BAR"){
		hours = hours +2;
	}else if(timezone == "TYO"){
		hours = hours +9;
	}else if(timezone == "SYD"){
		hours = hours +10;
	}

  	hours = (hours > 23 ?  hours - 24 : hours);
  	hours = (hours < 0 ?  hours + 24 : hours);
  
  	// Pad the minutes and seconds with leading zeros, if required
  	mins = ( mins < 10 ? "0" : "" ) + mins;
  	hours = ( hours < 10 ? "0" : "" ) + hours;
  
  	var currentTimeMins = "<font color='#F5F7F6'>" + hours + ":" + mins;
  	
  	return currentTimeMins;
}
