微信小程序云开发 addDelayedFunctionTask开启本地调试才能触发?
// 云函数入口函数
exports.main = async (event, context) => {
let num = new Date(event.date).getTime() - new Date().getTime()
let delayTime = parseInt(Math.abs(num / 1000))
event.content += `-${delayTime}`
console.log('event.date', event.date);
console.log('new Date()', new Date());
console.log(delayTime);
console.log(event.content);
try {
const result = await cloud.openapi.cloudbase.addDelayedFunctionTask({
"env": 'xxxxx',
"data": JSON.stringify(event),
"functionName": 'sendMsg',
"delayTime": delayTime
})
return result
} catch (err) {
console.log('err', err);
return err
}
}
只有我将该云函数启动本地调试才会触发对应的方法 经过排查是由于new Date('2022-10-31 16:20:00')转换成了2022-10-31T16:20:00.000Z实际上应该是2022-10-31T08:20:00.000Z 这是为什么