效果:
当前时间:2013年6月20日 星期一12:0:19
例子:
<mce:script language="javascript"><!--
function getTimeNow() {
var time = new Date();
var hour = time.getHours();
var minute = time.getMinutes();
var second = time.getSeconds();
var week; var date;
if(time.getDay()==0) week="星期日";
if(time.getDay()==1) week="星期一";
if(time.getDay()==2) week="星期二";
if(time.getDay()==3) week="星期三";
if(time.getDay()==4) week="星期四";
if(time.getDay()==5) week="星期五";
if(time.getDay()==6) week="星期六";
date=(time.getYear())+"年"+(time.getMonth()+1)+"月"+time.getDate()+"日"+" ";
document.getElementById("nowTime").innerHTML ="当前时间:"+date+week+ hour+":"+minute+":"+second;
setTimeout("getTimeNow()",1000);
}
// --></mce:script>
在页面中这样调用: