Step One
Paste the following JavaScript code into the <HEAD> of your Web page:
Paste the following JavaScript code into the <HEAD> of your Web page:
<SCRIPT language="javascript">Step Two
<!-- hide javascript
function StartClock12() {
Time12 = new Date();
Cur12Hour = Time12.getHours();
Cur12Mins = Time12.getMinutes();
Cur12Secs = Time12.getSeconds();
The12Time = (Cur12Hour > 12) ? Cur12Hour - 12 : Cur12Hour;
The12Time += ((Cur12Mins < 10) ? ':0' : ':') + Cur12Mins;
The12Time += ((Cur12Secs < 10) ? ':0' : ':') + Cur12Secs;
The12Time += (Cur12Hour > 12) ? ' PM': ' AM';
document.CForm.Clock12.value = The12Time;
window.status = The12Time;
setTimeout('StartClock12()',1000);
}function StartDate() {
TDay = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
TMonth = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
TDate = new Date();
CurYear = TDate.getYear();
CurMonth = TDate.getMonth();
CurDayOw = TDate.getDay();
CurDay= TDate.getDate();
TheDate = TDay[CurDayOw] + ', ';
TheDate += TMonth[CurMonth] + ' ';
TheDate += CurDay + ', ';
TheDate += ((CurYear%1900)+1900);
document.CForm.CDate.value = TheDate;
}// done hiding --></SCRIPT>
Add the onLoad event handler to the page's <BODY> tag:
<BODY onLoad="StartClock12();StartDate()";>Step Three
Then paste the code below into the <BODY> section (add layout and decoration as you see fit):
<FORM name="CForm">That's it.
<INPUT type="text" name="Clock12" size="12">
<INPUT type="text" name="CDate" size="29">
</FORM>

0 Responses to "Insert current date and time in website":
Post a Comment