Search code examples
reactjsexpresszoom-sdk

Zoom api respons with wrong date on creating meetings


i have an app to create and schedule meetings with zoom and this is how it works

  1. React app sends data to my Express REST API
  2. Express API forwards data to Zoom API
  3. Response from Zoom API is stored in Mongo DB

In React i send data as start_time: dateTime.toISOString().

I have logged Request and Response from both client and API:

for time 2019-09-25 04:00PM GMT +5:30 (IST)

  • On Request: start_time: '2021-09-25T10:30:00.000Z'
  • API Response: start_time:"2021-09-25T09:41:58Z"

when converted in client side new Date(start_time) returns the current time at which i created the request.

for time 2019-09-26 05:30PM GMT +5:30 (IST)

  • On Request: start_time: '2021-09-25T12:00:00.000Z'
  • API Response: start_time:"2021-09-26T06:30:12Z"

when converted to date produces Time 12:00PM.

I create meetings with zoom APi like so and after receiving API Response i store response data to Mongo DB:

  axios(config)
    .then(function (response) {
      response.data["participants"] = participants;
      const newMeeting = new Meeting(response.data);
      try {
        newMeeting
          .save()
          .exec()
          .then((meeting) => {
            console.log("Successfully store meeting to database");
          });
      } catch (err) {
        console.error(err);
      }
      res.json(response.data);
    })
    .catch(function (err) {
      console.error(err);
    });

how could i tackle this issue?


Solution

  • I also faced same problem.

    It was due to difference in local time and UTC time.

    This is how I managed to resolve this issue.

    Created UTC dateTime String in this format 04/04/2022 07:48:27 PM UTC using moment.js and used that formated String UTCDateTime in javascript Date Object. Code Example givin below It may help you.

    var UTCDateTime=moment(dateTime).format("MM/DD/YYYY hh:mm:ss A UTC");
    var meetingTime = new Date(UTCDateTime);
    

    Used meetingTime for meeting start_time and it worked for me.

    start_time : meetingTime