0
点赞
收藏
分享

微信扫一扫

javascript  在文本框中…

妖妖妈 2022-07-27 阅读 72

<!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>
<script language="javascript">
window.onload = function getTime(){
var st = showtime();
//对文本框赋值
document.getElementByIdx_x("clock").value = st;}
function showtime()
{
today=new Date();
var year=today.getYear();
var month=today.getMonth()+1;
var day=today.getDate();
var hours=today.getHours();
var minutes=today.getMinutes();
var seconds=today.getSeconds();
var timeValue= year;
timeValue += ((month < 10) ? "-0" : "-") + month+"";
timeValue += ((day < 10) ? "-0" : "-") + day+"";
timeValue += ((hours < 12) ? "-0" : " ") + hours+"";
timeValue += ((minutes < 10) ? "-0" : ":") + minutes+"";
timeValue += ((seconds < 10) ? "-0" : ":") + seconds+"";return timeValue;
}
</script></head>
<body>
<input type="text" id="clock" />
</body>
</html>

举报

相关推荐

0 条评论