123456789101112131415161718192021222324252627282930313233343536373839 |
- //获取动态时间
- var t = null;
- t = setTimeout(time,1000);// 开始执行
- function time()
- {
- clearTimeout(t);// 清除定时器
- dt = new Date();
- var y=dt.getYear()+1900;
- var mm=dt.getMonth()+1;
- var d=dt.getDate();
- var weekday=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
- var day=dt.getDay();
- var h=dt.getHours();
- var m=dt.getMinutes();
- var s=dt.getSeconds();
- if(h<10){h="0"+h;}
- if(m<10){m="0"+m;}
- if(s<10){s="0"+s;}
- $("#time").html( y+"年"+mm+"月"+d+"日 "+weekday[day]+" "+h+":"+m+":"+s+"");
- t = setTimeout(time,1000); // 设定定时器,循环执行
- }
- /**
- *
- * @param hex 例如:"#23ff45"
- * @param opacity 透明度
- * @returns {string}
- */
- function hexToRgba(hex, opacity) {
- return "rgba(" + parseInt("0x" + hex.slice(1, 3)) + "," + parseInt("0x" + hex.slice(3, 5)) + "," + parseInt("0x" + hex.slice(5, 7)) + "," + opacity + ")";
- }
- function test()
- {
- var hex1='#2c69a8';
- var opt1='0.5';
- var result=hexToRgba(hex1,opt1);
- }
|