//系统时间 2019年12月10日 星期一 21:49:50
function timeStr() {
var str;
var hhText = "上午"
var hh = new Date().getHours();
if (hh < 6) { hhText = "凌晨好!" }
else if (hh < 9) { hhText = "早上" }
else if (hh < 12) { hhText = "上午" }
else if (hh < 14) { hhText = "中午" }
else if (hh < 17) { hhText = "下午" }
else if (hh < 19) { hhText = "傍晚" }
else if (hh < 22) { hhText = "晚上" }
else { hhText = "晚上" }
if (hh < 10) hh = '0' + hh;
var mm = new Date().getMinutes();
if (mm < 10) mm = '0' + mm;
var ss = new Date().getSeconds();
if (ss < 10) ss = '0' + ss;
var yy = new Date().getYear();
if (yy < 1900) yy = yy + 1900;
var MM = new Date().getMonth() + 1;
if (MM < 10) MM = '0' + MM;
var dd = new Date().getDate();
if (dd < 10) dd = '0' + dd;
var ww = new Date().getDay();
if (ww == 0) ww = '星期日';
if (ww == 1) ww = '星期一';
if (ww == 2) ww = '星期二';
if (ww == 3) ww = '星期三';
if (ww == 4) ww = '星期四';
if (ww == 5) ww = '星期五';
if (ww == 6) ww = '星期六';
//2019年12月10日 星期一 21:49:50
str = yy + '年' + MM + '月' + dd + '日' + '|' + ww + '|' + hh + ':' + mm + ':' + ss + '|' + hhText;
return (str);
}
console.log(timeStr()); //2019年12月10日 星期一 21:49:50
timeText();
function timeText() {
var domStr = timeStr();
$(".ymd").text(domStr.split("|")[0]);
$(".xq").text(domStr.split("|")[1]);
$(".hhText").text(domStr.split("|")[3]);
$(".week").text(domStr.split("|")[2]);
setTimeout(timeText, 1000);
}