admin 管理员组

文章数量: 1184232


2024年3月8日发(作者:八位二进制加密是啥)

JS获取当前时间,显示“上午”、“下午”

最后效果如:下午 4:44:20 这样的格式,并且时间的秒数是变化的

这个网页特效代码如下

< head>

< meta http-equiv="Content-Type" content="text/html; charset=gb2312">

< title>JS获取当前时间,显示“上午”、“下午”丨芯晴网页特效丨

< /head>

< body onload="startclock()">

< script language=JavaScript>

var timerID = null;

var timerRunning = false;

function stopclock (){

if(timerRunning)

clearTimeout(timerID);

timerRunning = false;}

function startclock () {

stopclock();

showtime();}

function showtime () {

var now = new Date();

var hours = rs();

var minutes = utes();

var seconds = onds()

var timeValue = "" +((hours >= 12) ? "下午 " : "上午 " )

timeValue += ((hours >12) ? hours -12 :hours)

timeValue += ((minutes < 10) ? ":0" : ":") + minutes

timeValue += ((seconds < 10) ? ":0" : ":") + seconds

= timeValue;

timerID = setTimeout("showtime()",1000);

timerRunning = true;}

< /SCRIPT>

< form name=clock >

< input name=thetime style="font-size: 9pt;color:#000000;border:0"

size=12>

< /form>

< /body>

< /html>


本文标签: 时间 获取 显示 加密 网页