VodaPayAPI"request-time"header是什么时间格式?

What time format is the VodaPay API "request-time" header?

当前的 toISOString() javascript 函数不提供 auth/payment 流 header“request-time”字段所需的正确格式。如何在 JavaScript 中为我的 API 请求实现正确的格式?

您可以使用此函数将日期转换为您使用的正确格式。

function dateToLocalISO(date) { 
    const off    = date.getTimezoneOffset()
    const absoff = Math.abs(off)
    return (new Date(date.getTime() - off*60*1000).toISOString().substr(0,23) +
            (off > 0 ? '-' : '+') + 
            Math.floor(absoff / 60).toFixed(0).padStart(2,'0') + ':' + 
            (absoff % 60).toString().padStart(2,'0'))
}

如果您使用 javascript 向后端服务器发出请求,您还可以使用 luxon npm 包

import {DateTime} from 'luxon';
const requestTime = DateTime.local().toISO();

它将以正确的 ISO 格式提供。 Luxon Documentation on toISO