總秒數 --> { hours, minutes, seconds }
/**
* @param {Number} seconds 總秒數
* @returns 包含hours, minutes, seconds 的對象
*/
function formatSecond (seconds) {
seconds = parseInt(seconds)
let minutes = 0
let hours = 0
if (seconds >= 60) {
minutes = parseInt(seconds / 60)
seconds = parseInt(seconds % 60)
}
if (minutes >= 60) {
hours = parseInt(minutes / 60)
minutes = parseInt(minutes % 60)
}
return {
hours: hours,
minutes: minutes,
seconds: seconds
}
}
function getNowFormatDate () {
let date = new Date()
let strDate = date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate()
return strDate
}
function date () {
let date = new Date()
let year = date.getFullYear() + ""
let month = date.getMonth() + 1 > 9 ? date.getMonth() + 1 : "0" + (date.getMonth() + 1)
let day = date.getDate() > 9 ? date.getDate() : "0" + date.getDate()
let formatDate = year + "-" + month + "-" + day
return {
year: year,
month: month,
day: day,
formatDate: formatDate
}
}