Time Zone Settings
The runtime environment of cloud functions maintains UTC time, which is the time in the 0 time zone, resulting in an 8-hour time difference from Beijing time.
You can use time processing libraries or packages in programming languages (such as moment-timezone) to identify UTC time and convert it to Beijing time (UTC+8).
Note: The current function version supported by Cloud Development is Node 10, which cannot specify the time zone by setting the environment variable TZ=Asia/Shanghai (Node 15+ versions support this).
Reference code:
const moment = require("moment-timezone"); // Requires specifying and installing dependencies in package.json
exports.main = async (event, context) => {
// javascript date
console.log(new Date()); // 2021-03-16T08:04:07.441Z (UTC+0)
console.log(moment().tz("Asia/Shanghai").format()); // 2021-03-16T16:04:07+08:00 (UTC+8)
};