JS获取当前时间? 格式 年月日 星期几 显示阴历日期? 节气
? ? ? 显示结果格式:2013年07月06日 星期六 农历癸巳年 五月廿八 明日 小暑
?
?
?
????? 调用格式:
?????? //获取当前时间
?????? var nowDateInfo = getNowDate();
?????? //$("#nowDateInfo").html(nowDateInfo);
?????? document.getElementById("nowDateInfo").innerHTML = nowDateInfo;
?
????? 2, JS代码如下:
?
??????
? function getNowDate(){
??? var today=new Date();
??? var d=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
??? var nowDate= "";
??? ??? nowDate = showLocale();// 获取当前时间 年月日 时分秒
??? ??? nowDate = nowDate+ " "+ d[today.getDay()];// 获取当前星期
??? ??? nowDate = nowDate+ " "+ (CnDateofDateStr(today)); // 显示农历
??? ??? nowDate = nowDate+ " " +SolarTerm(today); // 显示二十四节气
??? ??? return nowDate;
}
function showLocale(){
??? var str;
??? var objD;
??? ??? objD = new Date();
??? var yy = objD.getYear();
??? ??? if(yy<1900){
??? ??? ??? yy = yy+1900;
??? ??? }
??? var MM = objD.getMonth()+1;
??? ??? if(MM<10){
??? ??? ??? MM = '0' + MM;
??? ??? }
??? var dd = objD.getDate();
??? ??? if(dd<10){
??? ??? ??? dd = '0' + dd;???
??? ??? }
??? var hh = objD.getHours();
??? ??? if(hh<10){
??? ??? ??? hh = '0' + hh;
??? ??? }
??? var mm = objD.getMinutes();
??? ??? if(mm<10){
??? ??? ??? mm = '0' + mm;
??? ??? }
??? var ss = objD.getSeconds();
??? ??? if(ss<10){
??? ??? ??? ss = '0' + ss;
??? ??? }
??? var ww = objD.getDay();
??? ??? // + hh + ":" + mm + ":" + ss +
??? ??? str = yy + "年" + MM + "月" + dd + "日? ?