显示当前时间,点击按钮,显示当前系统时间
代码如下
<script>
function tim() {
var date = new Date();//当前系统时间
var year = date.getFullYear();
var month = date.getMonth();
var de = date.getDate();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var time = document.querySelector("span");
time.innerHTML = year+'-'+month+'-'+de+' '+hours+':'+minutes+':'+seconds;
}
</script>