The code below works okay but I need to change the mm/dd/yy format. I can do this with other scripts but I want to use it in the form I've placed there. I took the date part out of the clock() function to try to make it work. Im just a struggling student. HELP! If I put it back in the function how do i change the format. Any advice welcome!!
thanks....xdef
<html><title>Clock</title>
<head>
<script Language="JavaScript">
<!-- hide
var timeStr,dateStr;
function clock() {
now= new Date();
hours= now.getHours();
minutes= now.getMinutes();
seconds= now.getSeconds();
timeStr= "" + hours;
timeStr+= ((minutes < 10) ? ":0" : ":") + minutes;
timeStr+= ((seconds < 10) ? ":0" : ":") + seconds;
document.clock.time.value = timeStr;
// date
date= now.getDate();
month= now.getMonth()+1;
year= now.getYear();
dateStr= "" + month;
dateStr+= ((date < 10) ? "/0" : "/") + date;
dateStr+= "/" + year;
document.clock.date.value = dateStr;
Timer= setTimeout("clock()",1000);
}
//-->
</script>
</head>
<body bgcolor="red" onLoad="clock()">
<div align="center">
<form name="clock">
Time:
<input type="text" name="time" size="16" value=http://www.webdeveloper.com/forum/archive/index.php/"">
Date:
<input type="text" name="date" size="16" value="">
</form>
<input type='button' value='http://www.webdeveloper.com/forum/archive/index.php/EXIT' onClick='parent.close()'><br>
</div>
</body></html>
thanks....xdef
<html><title>Clock</title>
<head>
<script Language="JavaScript">
<!-- hide
var timeStr,dateStr;
function clock() {
now= new Date();
hours= now.getHours();
minutes= now.getMinutes();
seconds= now.getSeconds();
timeStr= "" + hours;
timeStr+= ((minutes < 10) ? ":0" : ":") + minutes;
timeStr+= ((seconds < 10) ? ":0" : ":") + seconds;
document.clock.time.value = timeStr;
// date
date= now.getDate();
month= now.getMonth()+1;
year= now.getYear();
dateStr= "" + month;
dateStr+= ((date < 10) ? "/0" : "/") + date;
dateStr+= "/" + year;
document.clock.date.value = dateStr;
Timer= setTimeout("clock()",1000);
}
//-->
</script>
</head>
<body bgcolor="red" onLoad="clock()">
<div align="center">
<form name="clock">
Time:
<input type="text" name="time" size="16" value=http://www.webdeveloper.com/forum/archive/index.php/"">
Date:
<input type="text" name="date" size="16" value="">
</form>
<input type='button' value='http://www.webdeveloper.com/forum/archive/index.php/EXIT' onClick='parent.close()'><br>
</div>
</body></html>