日期:2014-05-17 浏览次数:20748 次
<form name="form1">
<input type="text" name="date" id="date" />
<input type="text" name="time" id="time"/>
<script type="text/javascript">
var now = new Date();
var year = now.getFullYear() + "-";
var month = (now.getMonth() + 1) ;
var day = now.getDate();
if(month < 10)
{
month = "0" + month;
}
var date = year + month + "-" + day;
document.form1.date.value = date;
</script>
</form>
<script type="text/javascript">
setInterval("time()",1000);
</script>
function time()
{
var time = new Date().toLocaleString();
document.form1.time.value = time;
}
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script type="text/JavaScript">
function timer()
{
var today=new Date();
var yy=today.getFullYear();
var month=today.getMonth()+1;
var day=today.getDate();
var hh=today.getHours();
var mm=today.getMinutes();
var ss=today.getSeconds();
document.getElementById("txt1").value=yy+"-"+month+"-"+day;
document.getElementById("txt2").value=hh+":"+mm+":"+ss;
}
var t=setInterval("timer()",1000)
</script>
<body>
<div >
date:
<input type="text" name="txt1" value="" id="txt1">
time:
<input type="text" name="txt2" value="" id="txt2">
</div>
</body>
</html>