一、js 获取当前时间
<script>
var nowTime = new Date()
var materialid = Date.parse(new Date())
const month = nowTime.getMonth() + 1 < 10 ? '0' + (nowTime.getMonth() + 1) : nowTime.getMonth() + 1
const day = nowTime.getDate() < 10 ? '0' + nowTime.getDate() : nowTime.getDate()
const hours = nowTime.getHours() < 10 ? '0' + nowTime.getHours() : nowTime.getHours()
const min = nowTime.getMinutes() < 10 ? '0' + nowTime.getMinutes() : nowTime.getMinutes()
const sec = nowTime.getSeconds() < 10 ? '0' + nowTime.getSeconds() : nowTime.getSeconds()
const numTime = nowTime.getFullYear() + '-' + month + '-' + day + ' ' + hours + ':' + min + ':' + sec
const textTime = nowTime.getFullYear() + '年' + month + '月' + day + '日' + ' ' + hours + '时' + min + '分' + sec + '秒'
console.log('获取时间戳:', materialid)
console.log('日期:',numTime)
console.log('汉字日期:',textTime)
</script>