8

电脑技术:一个带毫秒的时间显示页面

 3 years ago
source link: https://www.taholab.com/23850
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

电脑技术:一个带毫秒的时间显示页面

By: taho
On: 2021年9月28日
Tagged: 电脑技术
With: 0 Comments

由于最近要测试一下图传的延迟,需要看一下差多少毫秒。无奈搜遍网页,也没有一个简单的带毫秒的时钟,于是就在网上找代码做了一个非常简单的页面,满足时间带毫秒的需求。



网页代码:

<html>
<head>
<title>显示带有3位数毫秒的时间</title>
</style>
<script type="text/javascript">
function startTime()
var today=new Date()
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
var ms=today.getMilliseconds()
// add a zero in front of numbers<10
m=checkTime(m)
s=checkTime(s)
ms=checkTime2(ms);
document.getElementById('show_time').innerHTML=h+":"+m+":"+s+":"+ms;
t=setTimeout('startTime()',50)
function checkTime(i)
if (i<10)
{i="0" + i}
return i
function checkTime2(i)
if (i<10)
{i="00" + i;return i;}
if (i<100)
{i="0" + i;return i;}
return i;
</script>
</head>
<body onload="startTime()">
<div class="center_all">
<span style="font-size:150px;">
<font color="#000000">
<div id="show_time"></div>
</span>
</font>
</div>
<br></br>
<br></br>
<br></br>
<span style="color:#191970; font-size:40px;"> <a href="https://www.taholab.com">www.taholab.com</a></span>
</body>
</html>

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK