如何在 cliniko API 中设置正确的时间?

How to set the correct time in cliniko API?

我正在尝试做一个预订平台。我面临一个问题,当我将请求发送到 cliniko 的 API 时,我的时间被保留在一个比我发送请求的时段晚 4 小时的时段。这是我发出请求的代码

app.post('/makeBooking', (req, res) => {

  console.log('===========old=======start date: ',req.body.startDate)
  console.log('===========new=======end date: ',req.body.endDate)

  let newStartDate = moment.utc(req.body.startDate).format('YYYY-MM-DD HH:mm:ssZ')
  let newEndDate = moment.utc(req.body.endDate).format('YYYY-MM-DD HH:mm:ssZ')


   console.log('===========old=======start date: ',newStartDate)
  console.log('===========new=======end date: ', newEndDate)

  var data = JSON.stringify({
    "starts_at": newStartDate,
    "ends_at": newEndDate,
    "notes": req.body.note,
    "business_id": "436798402274003408",
    "practitioner_id": "436798398809508395",
    "patient_id": "6",
    "appointment_type_id": "436798401980402014"
  });

  axios(config)
    .then(function (response) {
      return res.status(200).json({ error: false, message: 'Success', data: response.data })
    })
    .catch(function (error) {
       console.log('==================================',error.response);
      console.log(error);
    });
})

我不确定将其转换为 utc 是否正确。我的时区是美国东部时间。

我可以通过像这样转换时区来解决这个问题

let newStartDate = moment(req.body.startDate, 'YYYY-MM-DD HH:mm:ss Z').utc().format()

let newEndDate = moment(req.body.endDate, 'YYYY-MM-DD HH:mm:ss Z').utc().format()

而不是这样做

let newStartDate = moment.utc(req.body.startDate).format('YYYY-MM-DDTHH:mm:ssZ')