// 将13位时间戳转化为YYYY-MM-dd HH:mm:ss
export const time_format = (time) => {
	if (time.toString().length === 13) {
		var date, y, m, d, h, mm, s
		date = new Date(time)
		y = date.getFullYear()
		m = (date.getMonth() + 1).toString().padStart(2, 0)
		d = date.getDate().toString().padStart(2, 0)
		h = date.getHours().toString().padStart(2, 0)
		mm = date.getMinutes().toString().padStart(2, 0)
		s = date.getSeconds().toString().padStart(2, 0)

		date = y + "-" + m + "-" + d + " " + h + ":" + mm + ":" + s
		return date
	} else {
		return '格式不正确'
	}
}

// 获取当前日期
export const getNowDate = () => {
	const date = new Date()
	let year = date.getFullYear()
	let month = (date.getMonth() + 1).toString().padStart(2, 0)
	let day = date.getDate()
	return `${year}-${month}-${day}`
}