function time(){ var date = new Date(); //获取系统时间 var year = date.getFullYear(); //当前公元年份 var month = date.getMonth(); //当前月份-1,所以后面显示的年份有+1 var day = date.getDate(); //当前天数,getDay()表示当前星期几 var hour = date.getHours(); //当前小时~小时,分钟,秒 get后面都有s var minute = date.getMinutes(); var second = date.getSeconds(); var $time = $("time"); var txt = year + "年" + (month + 1) + "月" + day + "日 " + hour + ":" + minute + ":" + second; $time.text(txt); } setInterval("time()",1000); //一秒更新一次
时间: 2024-12-28 23:50:13