Help

The Community will be temporarily unavailable starting on Friday February 28. We’ll be back as soon as we can! To learn more, check out our Announcements blog post.

Convert time to GMT+8

Topic Labels: Automations
1219 1
cancel
Showing results for 
Search instead for 
Did you mean: 
MCC
6 - Interface Innovator
6 - Interface Innovator

Hi, 

My script below functions to auto generate meeting time slot dates for my team. However, the time generated does not reflect the time zone I hoped for, i.e., Australia/Perth, UTC+8. In my data view, my "Time Slot" column is a "Date" set up as below.

MCC_0-1693364173878.png

Could anyone help me to identify what needs to be amended in my script?

Greatly appreciate any help here.

Thanks,

Eve

1 Reply 1
MCC
6 - Interface Innovator
6 - Interface Innovator
//pick tables from your base here
const tableName = base.getTable("Meeting Availability");

const startDate = new Date('2023-09-05');
const endDate = new Date('2023-09-05');
const startTime = 8 * 60 * 60; // 8:00 AM in milliseconds
const endTime = 16 * 60 * 60; // 4:00 PM in milliseconds
const slotDuration = 15 * 60; // 15 minutes in milliseconds

const dailyTimeSlots = [];

for (let currentDate = new Date(startDate); currentDate <= endDate; currentDate.setDate(currentDate.getDate() + 1)) {
    for (let currentTime = startTime; currentTime < endTime; currentTime += slotDuration) {
        const timeSlot = new Date(currentDate.getTime() + currentTime * 1000);
        dailyTimeSlots.push({
            fields: {
                "Time Slot": timeSlot,
                Duration: 900 // 15 minutes in seconds
            }
        });
    }
}

await tableName.createRecordsAsync(dailyTimeSlots);