Why is the Google Calendar Create Event app scheduling events on the wrong date?

This topic was automatically generated from Slack. You can find the original thread here.

I am having a problem with the GOOGLE CALENDAR CREATE EVENT app.

I passed it the starting date and time which was 10/14, however it went into my calendar for 10/13.

The starting date format said:
2023-09-23T00:00:00-0000

The ending date format said:
2023-09-23T00:00:00-0000

I’m sorry to hear that you’re having an issue with the Google Calendar Create Event app. To better assist you, can you please provide more details about the workflow you’ve set up and the specific trigger or action you’re using? This will help me understand the issue and provide a solution.

The workflow is creating a Google Calendar Event based on user input.

The trigger is a Google Form.

We ask for the STARTING DATE.

We ask for the ENDING DATE.

We ask for STARTING TIME.

We don’t ask for ENDING TIME.

How can I change the ending date format to say:
2023-09-23T23:59:59-0000

And it should be based on the person’s timezone.

To create a Google Calendar event with the correct ending date and time based on the user’s input, you can use the following code snippet in a Pipedream code step. This code assumes you have the starting date, ending date, and starting time from the Google Form trigger. ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { google: { type: “app”, app: “google”, }, startingDate: { type: “string”, label: “Starting Date”, }, endingDate: { type: “string”, label: “Ending Date”, }, startingTime: { type: “string”, label: “Starting Time”, }, }, async run({ steps, $ }) { // Parse the starting and ending dates const startDate = new Date(this.startingDate); const endDate = new Date(this.endingDate); // Set the starting time const [hours, minutes] = this.startingTime.split(“:”); startDate.setHours(hours, minutes); // Set the ending time to 23:59:59 endDate.setHours(23, 59, 59); // Format the dates in the required format const startDateTime = startDate.toISOString(); const endDateTime = endDate.toISOString(); // Create the Google Calendar event using the formatted dates const response = await axios($, { method: “POST”, url: “https://www.googleapis.com/calendar/v3/calendars/primary/events”, headers: { Authorization: Bearer ${this.google.$auth.oauth_access_token}, “Content-Type”: “application/json”, }, data: { summary: “Your event summary”, start: { dateTime: startDateTime, }, end: { dateTime: endDateTime, }, }, }); return response; }, });

Write me a script which will have a starting date filter that will take my STARTING DATE and TIME and format it to correctly to insert into Google Calendar.

To create a Google Calendar event with the correct starting date and time based on the user’s input, you can use the following code snippet in a Pipedream code step. This code assumes you have the starting date and starting time from a previous step or user input. ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { google: { type: “app”, app: “google”, }, startingDate: { type: “string”, label: “Starting Date”, }, startingTime: { type: “string”, label: “Starting Time”, }, }, async run({ steps, $ }) { // Parse the starting date const startDate = new Date(this.startingDate); // Set the starting time const [hours, minutes] = this.startingTime.split(“:”); startDate.setHours(hours, minutes); // Format the date in the required format const startDateTime = startDate.toISOString(); // Create the Google Calendar event using the formatted date const response = await axios($, { method: “POST”, url: “https://www.googleapis.com/calendar/v3/calendars/primary/events”, headers: { Authorization: Bearer ${this.google.$auth.oauth_access_token}, “Content-Type”: “application/json”, }, data: { summary: “Your event summary”, start: { dateTime: startDateTime, }, end: { dateTime: startDateTime, // You can modify this to set the desired end time }, }, }); return response; }, });

I would prefer this code be INDEPENDENT from Google.

I would prefer it to work as a FILTER.

So, write me a script that will ask me for the STARTING DATE and STARTING TIME and then it will return it back in the following format:

yyyy-mm-ddThh:mm:ss+01:00

Here’s a script that takes the starting date and starting time as input and returns the formatted date and time: export default defineComponent({ props: { startingDate: { type: "string", label: "Starting Date (yyyy-mm-dd)", }, startingTime: { type: "string", label: "Starting Time (hh:mm)", }, }, async run({ steps, $ }) { const startDate = new Date(this.startingDate); const [hours, minutes] = this.startingTime.split(":"); startDate.setHours(hours, minutes); const formattedDate = startDate.toISOString().replace(".000Z", "+01:00"); return formattedDate; }, }); This script will ask for the starting date and starting time, and then return the date and time in the format yyyy-mm-ddThh:mm:ss+01:00.

Perfect.

Thanks.

You’re welcome! If you have any more questions or need further assistance, feel free to ask. I’m here to help!