日期:2014-05-16 浏览次数:20356 次
//显示日期的js
function showtime()
??{
??var hour,second,minute,year,month,date;
??var strDate;
??var today=new Date();
??var n_day = today.getDay();
??switch(n_day)
??{
???case 0:
???{
????strDate = "星期日";
???}
???break;
???case 1:
???{
????strDate = "星期一";
???}
???break;
???case 2:
???{
????strDate ="星期二";
???}
???break;
???case 3:
???{
????strDate = "星期三";
???}
???break;
???case 4:
???{
????strDate = "星期四";
???}
???break;
???case 5:
???{
????strDate = "星期五";
???}
???break;
???case 6:
???{
????strDate = "星期六";
???}
???break;
???case 7:
???{
????strDate = "星期日";
???}
???break;
??}
????year = today.getYear(); //年
????month = today.getMonth()+1; //月
????date =today.getDate(); //日
????hour = today.getHours();//时
????minute =today.getMinutes();//分
????second = today.getSeconds(); //秒
????if(eval(hour)<10){hour="0"+hour;}
????if(eval(minute)<10){minute="0"+minute;}
????if(eval(second)<10){second="0"+second;}
????document.getElementById('time').innerHTML=" "+year + "年" + month + "月" + date + "日 " +strDate+""+hour+"时"+minute+"分"+second+"秒"; //显示时间
????setTimeout("showtime();", 1000); //设定函数自动执行时间为 1000ms(1 s)
}
?