Home > Web Front-end > JS Tutorial > JS time display effect code_time and date

JS time display effect code_time and date

WBOY
Release: 2016-05-16 18:47:45
Original
1274 people have browsed it
Copy code The code is as follows:

function settime()
{
var myyear,mymonth ,myweek,myday,mytime,mymin,myhour,mysec;
var mydate=new Date();
myyear=mydate.getFullYear();
mymonth=mydate.getMonth();
myday =mydate.getDate();
myhour=mydate.getHours();
mymin=mydate.getMinutes();
mysec=mydate.getSeconds();
mytime="Today is:" myyear "year" mymonth "month" myday "day" myhour ":" mymin ":" mysec;
document.getElementById('xwgtime').innerHTML=mytime;
setTimeout('settime()',1000 );
}

This will show the time! The script is really powerful. . . ! This method can also be used to make the website switch to another page after a certain amount of time!
For example:
Copy code The code is as follows:

function SetTime(NomeTime)
{
document.getElementById("TimeValue").innerHTML=NomeTime "Automatically log in after seconds";
NomeTime--;
if(NomeTime==-1)
{
document .getElementById("TimeValue").style.display="none";
return;
}
window.setTimeout("javascript:SetTime(" NomeTime ")",1000);
}

Where NomeTime is the initial time size, such as 10 seconds!
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template