Display Date and Time

[Total: 0    Average: 0/5]

My Script Display Date and Time in the Text box.

Head Code:

<SCRIPT language="JavaScript">
/*
 * Script edited for month offset (by 1) on 4/2003
 * by: Mike Robb - http://www.js-x.com/
 */
function JSClock() { 
var time = new Date(); 
var time1 = new Date(); 
var hour = time.getHours(); 
var minute = time.getMinutes(); 
var second = time.getSeconds(); 

var dd=time1.getDate();
var mm=time1.getMonth()+1;
var yy=time1.getYear();

var temp = "" + ((hour > 12) ? hour - 12 : hour); 
temp += ((minute < 10) ? ":0" : ":") + minute; 
temp += ((second < 10) ? ":0" : ":") + second; 
temp += (hour >= 12) ? " P.M." : " A.M."; 

var temp1 = mm+"/"+dd+"/"+yy; 

//document.clockForm.digits.value = temp 
var a=document.getElementById("digits"); 
a.value = temp; 
var a1=document.getElementById("digits1"); 
a1.value = temp1; 
id = setTimeout("JSClock()",1000)}; 
</script> 

Body Code:

<FORM NAME="clockForm">The current time is 
<INPUT TYPE="text" NAME="digits" id="digits" SIZE=12 VALUE=""><BR>The current date is 
<INPUT TYPE="text" NAME="digits1" id="digits1"SIZE=12 VALUE="">
<input type=button onclick="JSClock()" value="Start Clock Now"></FORM>

Times Viewed: 2

Leave a Reply

Your email address will not be published. Required fields are marked *