云函数中时间计算与本地为什么不一致?
代码段如下: const dateFns = require('date-fns')
exports.main = async (event, context) => {
const now = Date.now()
const { month = now } = event
const date = new Date(month)
log.info({
now,
month,
date
})
const stTime = dateFns.startOfMonth(date)
const endTime = dateFns.endOfMonth(date)
log.info({
stTime, endTime
})
}
本地调试结果如下,所计算的时间范围是 2020.10.1 到 2020.10.31: [图片] 云端运行结果如下,计算的时间范围变成了2020.9.1 到 2020.9.30 了: [图片]