Comment Post Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Aug 29, 2023 07:56 PM
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.
Could anyone help me to identify what needs to be amended in my script?
Greatly appreciate any help here.
Thanks,
Eve
1 Reply 1
Comment Post Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Aug 29, 2023 07:56 PM
//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);
