function getLocalTime () {
let date = new Date()
let dateYear = date.getFullYear() // 获取年
let dateMonth = date.getMonth() + 1 // 获取月
let dateDate = date.getDate() // 获取日
// let dateDay = date.getDay() // 获取当天星期
// let dateHours = date.getHours() // 获取小时
// let dateMinutes = date.getMinutes() // 获取分钟数
// let dateSecondes = date.getSeconds() // 获取秒数
// let dateMilliseconds = date.getMilliseconds() // 获取毫秒数
const formatNumber = n => {
n = n.toString()
return n[1] ? n : '0' + n
}
let year = dateYear
let month = `${dateYear}-${formatNumber(dateMonth)}`
let day = `${dateYear}-${formatNumber(dateMonth)}-${formatNumber(dateDate)}`
}
网友评论