<input value="show" type="button" onClick="javascript:var today =new Date();document.getElementById('time').value=today.toLocaleString()">
<input id="time" type="text" style="width:200px">
<input id="time" type="text" style="width:200px">
调试欢乐多
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<button onclick="document.getElementById('time').value = new Date().toLocaleString()">hide</button>
<input type="text" id="time" />
</body>
</html>
<body>
<script type="text/javascript">
function dateFormat(date, separator){
date = typeof date == "number" ? new Date(date) :
(typeof date == "string" ? new Date(Date.parse(date)) : date);
separator = typeof separator == "string" ? separator : "$1年$2月$3日 $4时$5分$6秒";
var str = "" + date.getFullYear() + "-" + (date.getMonth() + 101) + "-" + (date.getDate() + 100) + " " +
(date.getHours() + 100) + ":" +(date.getMinutes() + 100) + ":" + (date.getSeconds() + 100);
return str.replace(/^(\d+)-\d*(\d{2})-\d*(\d{2}) \d*(\d{2}):\d*(\d{2}):\d*(\d{2})$/g, separator);
}
function Test(){
var $ = document.getElementById;
var now = new Date();
$("TextDateTime").value = dateFormat(now);
$("TextDate").value = dateFormat(now, "$1-$2-$3");
$("TextTime").value = dateFormat(now, "$4:$5:$6");
}
</script><div>
<input id="TextDateTime" type="text" />
<input id="TextDate" type="text" />
<input id="TextTime" type="text" />
<input type="button" value="测试" onclick="Test();" />
</div>
</body>
</html>