Just touch JavaScript in the date built-in objects, thought these methods are too simple, the result of their own actual operation to write a clock effect is really the moment I got stuck, there are a few points to pay attention to. First look at the actual effect
To achieve such an effect
A certain day of the week, a few days, a few seconds.
Look at the code effect first
<script type= "text/javascript" >
Window.onload=function () {
Showdate ();
Countdown ();
}
function Showdate () {
var mydate=new Date ();
var year=mydate.getfullyear ();
The Var month=mydate.getmonth () +1;//month Range is 0月-November, so add a
var date=mydate.getdate ();
var day=mydate.getday ();
var hour=mydate.gethours ();
var minute=mydate.getminutes ();
var second=mydate.getseconds ();
var weekday=new Array (7);
weekday[0]= "Monday";
weekday[1]= "Tuesday";
weekday[2]= "Wednesday";
weekday[3]= "Thursday";
weekday[4]= "Friday";
weekday[5]= "Saturday";
weekday[6]= "Sunday";
document.getElementById ("showTime"). innerhtml=year+ ' +month+ ' month ' +date+ ' +weekday[day]+hour+ ' when ' +minute+ ' + second+ ' seconds ';
T=settimeout (' showdate () ', 500);
}
Note that the range of month objects provided by the system is 0 to 11, not 12, so var month=mydate.getmonth+1;
You must also set the SetTimeout function to enable dynamic refresh of the number of seconds on a Web page
Native JavaScript implements Web page display date clock effect