<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body></body>
<script>
// 获取表格数据
let date = new Date()
let year = date.getFullYear()
let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
let hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
let minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
let seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
let time = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
console.log(time)
</script>
</html>
打印结果