I developed a javascript function that shows me the current time. Until then I had no problems. The problem is that I can not call this function in the place I want ... how can I call it using this?
<script language="JavaScript">
function showTime() {
var timeNow = new Date();
var hours = timeNow.getHours();
var minutes = timeNow.getMinutes();
var seconds = timeNow.getSeconds();
var timeString = "" + ((hours > 24) ? hours - 12 : hours);
timeString += ((minutes < 10) ? ":0" : ":") + minutes;
timeString += ((seconds < 10) ? ":0" : ":") + seconds;
timeString += (hours >= 12) ? " P.M." : " A.M.";
document.htmlClock.timeField.value = timeString;
timerID = setTimeout("showTime()", 1000);
}
</script>
Location where I want to call the function
<li><a href="#"><i class="fa fa-clock-o"></i>Hours here</a></li>
Automatically. What do you mean by that? When the page loads or based on a frequency or when the user clicks on something or....