var dt = new Date();
var year = dt.getFullYear();
var month = dt.getMonth() + 1;
var day = dt.getDate();
var hour = dt.getHours();
var minute = dt.getMinutes();
var second = dt.getSeconds();
alert(year+"年"+month+"月"+day+"日 "+hour+"时"+minute+"分"+second+"秒");
计算十位: Math.floor(hour/10)
计算个位: hour%10
每秒中重复调用time()函数: setTimeout("time();",1000);