3 回复
const getHoursSeconds = timestamp => {
console.log(‘timestamp’,timestamp)
var date = new Date(timestamp)
var Y = date.getFullYear() + ‘-’
var M = (date.getMonth()+1 < 10 ? ‘0’+(date.getMonth()+1) : date.getMonth()+1) + ‘-’;
var D = date.getDate() + ‘’;
var h = date.getHours()
var m = date.getMinutes()
var s = date.getSeconds()
m < 10 ? m = ‘0’ + m : m
console.log(‘h’, h, ‘m’, m)
return `${h}:${m}`
}
网页 10:00 正确
小程序 18:00 错误