You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.7 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

document.write('<div style="position:absolute;width:4.2%;height:2%;top: 2.1%;left: 84.14%;border: 0 solid red;color:#71D7FF;font-size:0.08rem;">\n' +
' <span id="timeinfo"></span>\n' +
'</div>\n' +
'\n' +
'<div style="position:absolute;width:6%;height:2%;top: 2.1%;left: 92%;border: 0 solid red;color:#71D7FF;font-size:0.08rem;">\n' +
' <span id="dateinfo"></span>\n' +
'</div>\n')
/*alert($(window).height());
var sonStyle = document.getElementsByClassName("son");
sonStyle.style.height = $(window).height()-500 + "px";*/
let rootWidth = document.documentElement.clientWidth || document.body.clientWidth;
let rootDom = document.querySelector('html');
rootDom.style.fontSize = rootWidth / 10 + 'px';
getnow();
function getnow(){
//1、获得当前时间格式化时间
var now=new Date();
var year=now.getFullYear();
var month=now.getMonth()+1;
if(month<10){
month="0"+month;
}
var date=now.getDate();
if(date<10){
date="0"+date;
}
var hour=now.getHours();
if(hour<10){
hour="0"+hour;
}
var minute=now.getMinutes();
if(minute<10){
minute="0"+minute;
}
var second=now.getSeconds();
if(second<10){
second="0"+second;
}
var nowstr=year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second;
//alert(nowstr);
//alert(nowstr);
//2、显示时间 html
//获得标签对象
/*var nowspan=document.getElementById("nowspan");
nowspan.innerHTML=nowstr;*/
//2021-09-30 12:00:00
$("#dateinfo").html(nowstr.slice(0,10));
$("#timeinfo").html(nowstr.slice(11,19));
//3、使时间动起来
setTimeout("getnow()", 1000);
}