当前日期时间

mac2026-06-11  11

//当前日期 var time = CurentTime(); $("#time_p").html(time); setInterval(function(){ var time1 = CurentTime(); $("#time_p").html(time1); },1000) function CurentTime() { var now = new Date(); var year = now.getFullYear(); //年 var month = now.getMonth() + 1; //月 var day = now.getDate(); //日 var hh = now.getHours(); //时 var mm = now.getMinutes(); //分 var ss = now.getSeconds(); //秒 var clock = year + "年"; if(month < 10) clock += "0"; clock += month + "月"; if(day < 10) clock += "0"; clock += day + "日 "; if(hh < 10) clock += "0"; clock += hh + ":"; if (mm < 10) clock += '0'; clock += mm + ":"; if (ss < 10) clock += '0'; clock += ss + " " ; var weekday=new Array(7) weekday[0]="星期日" weekday[1]="星期一" weekday[2]="星期二" weekday[3]="星期三" weekday[4]="星期四" weekday[5]="星期五" weekday[6]="星期六" clock += weekday[now.getDay()] return(clock); }

 

最新回复(0)