boardtime.js.下载 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //获取动态时间
  2. var t = null;
  3. t = setTimeout(time,1000);// 开始执行
  4. function time()
  5. {
  6. clearTimeout(t);// 清除定时器
  7. dt = new Date();
  8. var y=dt.getYear()+1900;
  9. var mm=dt.getMonth()+1;
  10. var d=dt.getDate();
  11. var weekday=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
  12. var day=dt.getDay();
  13. var h=dt.getHours();
  14. var m=dt.getMinutes();
  15. var s=dt.getSeconds();
  16. if(h<10){h="0"+h;}
  17. if(m<10){m="0"+m;}
  18. if(s<10){s="0"+s;}
  19. $("#time").html( y+"年"+mm+"月"+d+"日&nbsp;"+weekday[day]+"&nbsp;"+h+":"+m+":"+s+"");
  20. t = setTimeout(time,1000); // 设定定时器,循环执行
  21. }
  22. /**
  23. *
  24. * @param hex 例如:"#23ff45"
  25. * @param opacity 透明度
  26. * @returns {string}
  27. */
  28. function hexToRgba(hex, opacity) {
  29. return "rgba(" + parseInt("0x" + hex.slice(1, 3)) + "," + parseInt("0x" + hex.slice(3, 5)) + "," + parseInt("0x" + hex.slice(5, 7)) + "," + opacity + ")";
  30. }
  31. function test()
  32. {
  33. var hex1='#2c69a8';
  34. var opt1='0.5';
  35. var result=hexToRgba(hex1,opt1);
  36. }