html
創(chuàng)新互聯(lián)是一家專注于成都網站建設、網站制作與策劃設計,蓋州網站建設哪家好?創(chuàng)新互聯(lián)做網站,專注于網站建設十載,網設計領域的專業(yè)建站公司;建站業(yè)務涵蓋:蓋州等地區(qū)。蓋州做網站價格咨詢:18982081108
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
meta name="keywords" content="js特效" /
meta name="description" content="js特效網" /
title年月日分秒全部顯示的時間代碼/title
/head
body onload=startclock()
form name="clock"
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 = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = now.getYear()+"年"+(now.getMonth()+1)+"月"+now.getDate()+"日" +((hours = 12) ? " 下午 " : " 上午 " )
timeValue += ((hours 12) ? hours -12 :hours)
timeValue += ((minutes 10) ? ":0" : ":") + minutes
timeValue += ((seconds 10) ? ":0" : ":") + seconds
document.clock.thetime.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;}
/script
input name="thetime" style="font-size: 9pt;color:#000000;border:1px solid #FFFFFF; ; " size="28"/form
/body
/html
!DOCTYPE html
html lang="en"
head
meta charset="UTF-8"
titleDocument/title
style
*{margin:0;padding:0;}
.tdemo{width: 600px;height: 400px;margin:100px auto;}
.ttitle{background:#dfdfdf;height:50px;text-align:center;}
.tcontent{background:#eee;height:300px;}
.cnt{padding:20px 25px;}
.cnt p{line-height:25px;font-size:15px;color:#222;}
.tcontent h6{text-indent:25px;font-size:16px;color:#111;}
.tcontent p.last{text-indent:25px;}
.tfoot{background:#aaa;height:50px;}
.tfoot button{width: 60px;height: 28px;float: right;margin-right: 30px;}
/style
/head
body
table class="tdemo"
tr class="ttitle"
td
span id="time"/span
/td
/tr
tr class="tcontent"
td
h6謎面:/h6
div class="cnt"
p1.一只羊在吃草,一只狼從旁邊經過沒有吃羊。/p
p2.又一只狼經過,還是沒有吃羊。/p
p3.第三只狼經過,羊沖狼大叫,狼還是沒有吃羊。/p
? ?/div
p class="last"打:三種動物/p
/td
/tr
tr class="tfoot"
td
button查看謎底/button
/td
/tr
/table
script
var showzone=document.getElementById("time");
var time=new Date();
? ?var yy=time.getFullYear();
var mm=time.getMonth()+1;
var dd=time.getDate();
var kk=time.getDay();
var xingqi;
if(kk==0){
k="星期天"
}
else if(kk==1){
xingqi="星期一";
}
else if(kk==2){
xingqi="星期二"
}
else if(kk==3){
xingqi="星期三"
}
else if(kk==4){
xingqi="星期四"
}
else if(kk==5){
xingqi="星期五"
}
else{
xingqi="星期六";
}
? showzone.innerHTML="今天是:"+yy+"年"+mm+"月"+dd+"日"+xingqi+" ? ---歡迎你來猜一猜";
/script
/body
/html
diva href="#" style="float:left; text-align:left; margin-left:10px;"文字列表內容/aspan style="clear:both;float:right; margin-right:20px;"時間/span/div
至于時間不顯示年,要改js代碼,一般是把年份隱藏,有是系統(tǒng)時間,要代碼控制的。
td width="23%" align="left"今天是:
script language="JavaScript" type="text/javascript"
var day="";
var month="";
var ampm="";
var ampmhour="";
var myweekday="";
var year="";
mydate=new Date();
myweekday=mydate.getDay();
mymonth=mydate.getMonth()+1;
myday= mydate.getDate();
myyear= mydate.getYear();
year=(myyear 200) ? myyear : 1900 + myyear;
if(myweekday == 0)
weekday=" 星期日 ";
else if(myweekday == 1)
weekday=" 星期一 ";
else if(myweekday == 2)
weekday=" 星期二 ";
else if(myweekday == 3)
weekday=" 星期三 ";
else if(myweekday == 4)
weekday=" 星期四 ";
else if(myweekday == 5)
weekday=" 星期五 ";
else if(myweekday == 6)
weekday=" 星期六 ";
document.write(year+"年"+mymonth+"月"+myday+"日 "+weekday);/script/td