js获取当前时间
作者:互联网
<script>
function nowtime()
{
var date =new Date();
//当前年份
var year=date.getFullYear();
//当前月份
var month=date.getMonth()+1;
//当前天数
var day=date.getDate();
//当前小时
var hour=date.getHours();
//当前分钟
var minutes=date.getMinutes();
//当前秒
var seconds=date.getSeconds();
//当前星期
var weeks=date.getDay();
var days=["天","一","二","三","四","五","六"];
var showtime=document.getElementById("showtime");
showtime.innerHTML=year+"年"+month+"月"+day+"日"+hour+"时"+minutes+"分"+seconds+"秒"+"星期"+days[weeks];
}
//每秒执行一次
window.setInterval('nowtime()',1000);
</script>
标签:date,showtime,nowtime,js,获取,当前,var,month 来源: https://www.cnblogs.com/mofale/p/15350549.html