title: Why does Google Calendar API insert my event 4 hours earlier than the date/time that I've given it using Node.js?
body: <p>I have finally got the google calendar api to insert events into my calendar with Node.js, but the event is inserted 4 hours earlier than the start time that I've given it.</p>
  <p>Here's what I've done to get it to insert. In this example:
  the date variable is '2022-05-18' and
  the time variable is '17:18' and
  then when I console.log the apptDate variable, the output is 2022-05-18T17:18:00.000Z</p>
  <p>but the event is inserted in my calendar on 2022-05-18 at 13:18.</p>
  <pre><code>export const insertGoogleCalendarEvent = async (req, res)=&gt; {
      try{
      const {firstName, lastName, date, time, duration} = req.body
  
      const apptDate = new Date(`${date}T${time}:00.000Z`).toISOString()
  
      const SCOPES = ['https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/calendar.events']
      const GOOGLE_PRIVATE_KEY = process.env.GOOGLE_PRIVATE_KEY
      const GOOGLE_CLIENT_EMAIL = process.env.GOOGLE_CLIENT_EMAIL
      const GOOGLE_PROJECT_NUMBER = process.env.GOOGLE_PROJECT_NUMBER
      const GOOGLE_CALENDAR_ID = process.env.GOOGLE_CALENDAR_ID
  
      let endDateTime = ''
      if (duration === '60') {
          let newDate = new Date(apptDate)
          newDate.setHours(newDate.getHours() + 1)
          endDateTime = newDate.toISOString()
      } else if (duration === '75') {
          let newDate = new Date(apptDate)
          newDate.setMinutes(newDate.getMinutes() + 75)
          endDateTime = newDate.toISOString()
      } else if (duration === '90') {
          let newDate = new Date(apptDate)
          newDate.setMinutes(newDate.getMinutes() + 90)
          endDateTime = newDate.toISOString()
      }
  
      const event = {
          'summary': `${firstName} ${lastName}`,
          'start': {
              'dateTime': `${apptDate}`,
              'timeZone': 'Canada/Eastern'
          },
          'end': {
              'dateTime': `${endDateTime}`,
              'timeZone': 'Canada/Eastern'
          }
      }
  
      const jwtClient = new google.auth.JWT(
          GOOGLE_CLIENT_EMAIL,
          null,
          GOOGLE_PRIVATE_KEY,
          SCOPES
      )
  
      const calendar = google.calendar({
          version: 'v3',
          project: GOOGLE_PROJECT_NUMBER,
          auth: jwtClient
      })
  
      
          calendar.events.insert({
              calendarId: GOOGLE_CALENDAR_ID,
              resource: event,
          }, {
              function (err, event) {
                  if (err) {
                      console.log('this is an error', err)
                      return
                  }
                  console.log('Event created:', event.htmlLink);
              }
          })
      } catch {
          console.log('error')
      }
  }
  </code></pre>