标题: 动态时钟的举例 [打印本页] 作者: superadmin 时间: 2007-10-5 21:11 标题: 动态时钟的举例 #######################JS代码#########################################
function Year_Month(){
var now = new Date();
var yy = now.getYear();
var mm = now.getMonth()+1;
var cl = '<font color="#000000">';
if (now.getDay() == 0) cl = '<font color="#c00000">';
if (now.getDay() == 6) cl = '<font color="#00c000">';
return(cl +'<font color="#FF7311">'+yy+'</font>'+ '<font color="000000">年</font>'+'<font color="#FF7311">'+mm+'</font>'+'<font color="000000">月</font>');
}
function Date_of_Today(){
var now = new Date();
var cl = '<font color="#000000">';
if (now.getDay() == 0) cl = '<font color="#c00000">';
if (now.getDay() == 6) cl = '<font color="#00c000">';
return(cl + '<font color="#FF7311">'+now.getDate()+'</font>'+ '<font color="000000">日</font>');
}
function Day_of_Today(){
var day = new Array();
day[0] = "<font color=000000>星期</font><font color=#FF7311>日</font>";
day[1] = "<font color=000000>星期</font><font color=#FF7311>一</font>";
day[2] = "<font color=000000>星期</font><font color=#FF7311>二</font>";
day[3] = "<font color=000000>星期</font><font color=#FF7311>三</font>";
day[4] = "<font color=000000>星期</font><font color=#FF7311>四</font>";
day[5] = "<font color=000000>星期</font><font color=#FF7311>五</font>";
day[6] = "<font color=000000>星期</font><font color=#FF7311>六</font>";
var now = new Date();
var cl = '<font color="#000000">';
if (now.getDay() == 0) cl = '<font color="#c00000">';
if (now.getDay() == 6) cl = '<font color="#00c000">';
return(cl + day[now.getDay()] + '</font>');
}
function CurentTime(){
var now = new Date();
var hh = now.getHours();
var mm = now.getMinutes();
var ss = now.getTime() % 60000;
ss = (ss - (ss % 1000)) / 1000;
var clock = hh+':';
if (mm < 10) clock += '0';
clock += mm+':';
if (ss < 10) clock += '0';
clock += ss;
return(clock);
}