Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

156
Visualizações
Timezone issue with .createEvent()

I have issues with the event time zone in my script. I browsed through many topics like this, but my beginner's skills did not allow me to transcribe the solutions to my own case ...

Here's my script:

function book1() {
var form = FormApp.getActiveForm();
var responses = form.getResponses();
var len = responses.length;
var last = len - 1;
var items = responses[last].getItemResponses();
var email = responses[last].getRespondentEmail();
var equipment = items[1].getResponse();
var datestart = items[2].getResponse();
var dateend = items[3].getResponse();
var cal = CalendarApp.getCalendarsByName(equipment)[0];
Logger.log(datestart);
Logger.log(dateend);
var start = new Date(datestart);
var end = new Date(dateend);
Logger.log('start '+start);
Logger.log('end '+end);

var allEvents = CalendarApp.getCalendarsByName(equipment)[0].getEvents(start, end);

if (allEvents.length < 1) {
var event = cal.createEvent(equipment, start, end)
.addGuest(email);

MailApp.sendEmail({
    to: email,
    subject: "Equipment " +equipment+ " booking confirmed",
    htmlBody: "Equipment " +equipment+ " available, please return it by " +dateend+ " and scan the QR code when returning it.",
  });
}

else {
  var blob = HtmlService.createHtmlOutputFromFile("calendariframe").getBlob();
  MailApp.sendEmail({
    to: email,
    subject: "Equipment  " +equipment+ " not available",
    htmlBody: blob.getDataAsString(),
  });};

}

I can't find the right way to use getTimezoneOffset() or Utilities.formatDate in the right way. Would you have any advice on where to integrate them in my script so that the createEvent() works in GMT+1?

Thank you very much in advance for your help!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Solution found thanks to Cooper!

I went to the scripts project settings, checked the "Show "appsscript.json" manifest file in editor" box, went to the appsscript.json script and changed the timezone ID.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda