具有中国特色的时间提醒,blogbus后台的时间提示js代码,封装后的代码点击下载:date.js
Code:function welcomeText(username) {
  var time = ['子时', '丑时', '寅时', '卯时', '辰时', '巳时', '午时', '未时', '申时', '酉时', '戌时', '亥时'];
  var text = ['夜半销魂,谁人歌', '雄鸡未鸣,身未起', '风雨如晦,平旦出', '旭日东升,无往复', '君子勿劳,朝食饱', '鸡栖于莳,河清定', '善行无迹,恒德足', '日过中天,骄未散 ', '哺鹊进食,斜阳归', '鸡栖于埘,日沉坡', '日暮将至,归田园', '人定归本,早安眠'];
  var arr_week = ['', '星期一','星期二','星期三','星期四','星期五','星期六','星期日'];
  hour = new Date().getHours();
  year = new Date().getFullYear();
  month = new Date().getMonth();
  dayx = new Date().getDate();
  monthx = month+1;
  week = arr_week[new Date().getDay()];
 
  hourx = Math.ceil(hour/2);
  if (hourx == 12) { hourx = 0; }
  var today = year+"年"+monthx+"月"+dayx+"日 "+week;
  second = new Date().getSeconds();
  if(second % 2 == 0){
   welcome = "<span class=\"userInfo\">"+username + "</span>&nbsp;<span class=\"greeting\" title=\""+today+"\"><strong>" + time[hourx] +  "</strong>&nbsp;&nbsp;" + text[hourx] + "</span>";
  }
  return welcome = "<span class=\"userInfo\">"+username + "</span>&nbsp;<span class=\"greeting\" title=\""+today+"\"><strong>" + time[hourx] +  "</strong>&nbsp;&nbsp;" + text[hourx] + "</span>";
}
在你要的地方调用:
Code:<script>document.write(welcomeText("您好,"))</script>
 
文章来源于 前端开发,网站设计,优化运营--mon的博客:http://monw3c.blogbus.com/logs/56304645.html