﻿document.writeln("<SCRIPT language=JavaScript> ");
document.writeln("<!-- ");
document.writeln("function showtime()");
document.writeln("{");
document.writeln("today=new Date(); ");
document.writeln("var year=today.getYear();");
document.writeln("var month=today.getMonth()+1;");
document.writeln("var day=today.getDate();");
document.writeln("var hours = today.getHours(); ");
document.writeln("var minutes = today.getMinutes(); ");
document.writeln("var seconds = today.getSeconds(); ");
document.writeln("var timeValue= hours;\/\/((hours >12) ? hours -12 :hours);");
document.writeln("timeValue += ((minutes < 10) ? \":0\" : \":\") + minutes+\"\"; ");
document.writeln("\/\/timeValue += (hours >= 12) ? \"PM\" : \"AM\"; ");
document.writeln("timeValue+=((seconds < 10) ? \":0\" : \":\") + seconds+\"\";");
document.writeln("var timetext=year+\"-\"+month+\"-\"+day+\" \"+timeValue");
document.writeln("\/\/document.write(\"<span  onclick=\\\"document.getElementById(\'time\').value=\'\"+timetext+\"\'\\\">\"+timetext+\"<\/span>\"); ");
document.writeln("document.getElementById(\"liveclock\").innerText = timetext; \/\/div的html是now这个字符串 ");
document.writeln("setTimeout(\"showtime()\",1000); \/\/设置过1000毫秒就是1秒，调用showtime方法 ");
document.writeln("}");
document.writeln(" ");
document.writeln("--> ");
document.writeln("<\/SCRIPT>");
document.writeln("<script language=\"javascript\"> ");
document.writeln("window.onload=function(){");
document.writeln("showtime();");
document.writeln("}");
document.writeln("<\/script>");
document.writeln("");
document.writeln("<span id=\"liveclock\"><\/span>");
//调用代码:在网页位置插入此代码<script language="javascript" src="date.js"></script>
