html text显示时间

gengzhizhen 2009-04-22 05:26:26
<input type="text" id="intime">
html中如何让上面的文本框显示hh:mm:ss格式时间
...全文
321 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
lonelyriver 2009-04-26
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 xiaojing7 的回复:]
HTML code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<script>
function show5()
{
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
var dn="AM"
if(hours>12){dn="PM"
hours=hours-12
}if(hours==0)

[/Quote]

好像有点问题哦
如果凌晨00:47分测试的话 它显示时间为 12:47 AM 为什么不是 00:47 AM呢 ??
Alextion_Jiang 2009-04-24
  • 打赏
  • 举报
回复
默哀 这样的问题也问
没有水准
随便百度下就很多啊!
yurui05 2009-04-24
  • 打赏
  • 举报
回复
自己写的, 你看看

<!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>



<form name="the_form">
<div align="center">
<input name="the_text" type="text" value="" />

</div>
</form>

<script language="javascript">
function theTime(){
var today=new Date();
var year=today.getYear();
var month=today.getMonth()+1; //月份+1
var date=today.getDate();
var day=today.getDay(); //星期几 0表示星期天
var hours=today.getHours();
var minutes=today.getMinutes();
var seconds=today.getSeconds();
hours=fixtime(hours); minutes=fixtime(minutes); seconds=fixtime(seconds);
var now=year+"年"+month+"月"+date+"日"+hours+":"+minutes+":"+seconds;
document.the_form.the_text.value=now;
setTimeout('theTime();',500);
}
function fixtime(time){
if(time<10)
time="0"+time;
return time;
}
theTime();
</script>


</body>
</html>

caiying2009 2009-04-22
  • 打赏
  • 举报
回复

<input type="text" id="intime">
<script language="javascript">
setInterval("document.getElementById('intime').value=new Date().toLocaleTimeString()",500)
</script>
etz2008 2009-04-22
  • 打赏
  • 举报
回复
www.xizi123.cn

<input type="text" name="intime">
intime.vlaue
xiaojing7 2009-04-22
  • 打赏
  • 举报
回复
kingsonchen 2009-04-22
  • 打赏
  • 举报
回复
到http://www.lamp9.cn/htmljs.html看下,有你想要的答案。
xiaojing7 2009-04-22
  • 打赏
  • 举报
回复

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<script>
function show5()
{
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
var dn="AM"
if(hours>12){dn="PM"
hours=hours-12
}if(hours==0)
hours=12
if(minutes<=9)
minutes="0"+minutes
if(seconds<=9)
seconds="0"+seconds
myclock=hours+":"+minutes+":"+seconds+" "+dn;
if(document.layers){
document.layers.liveclock.document.write(myclock)
document.layers.liveclock.document.close()
}else {
document.getElementById("intime").value=myclock;
}

setTimeout("show5()",1000)
}
window.onload=function(){
show5();
};
</script>
<BODY>
<input type="text" id="intime">
</BODY>
</HTML>

61,110

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧