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

152
Visualizações
getDatecreated in Appps Script returning the time of creation an hour later

When I try to get the time of creation of a file in Google Drive with the built in function getDateCreated() in the apps script, it returns the time an hour after the creation. My code is as follows

var folder = DriveApp.getFolderById(myFolderId);

  var contents = folder.getFiles();
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();

  var var_file;
  var var_name;
  var var_link;
  var var_owner;
  var var_time;

  while(contents.hasNext()){
    var_file = contents.next();
    var_name = var_file.getName();
    var_link = var_file.getUrl();
    var_owner = var_file.getOwner().getName();
    var_time = var_file.getDateCreated();
    sheet.appendRow([var_name,var_link,var_owner, var_time]);
  }

If time of creation of a file is 25/06/2022 22:48:39 The output of my code returns 25/06/2022 23:48:39 which is an error. Note: My time zone is UTC-5

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

0

I did some research on different built-in methods in Javascript and the .toLocaleTimeString() seems to work fine returning the actual time the file was created.

var_time = var_file.getDateCreated().toLocaleTimeString();

It's also quite important to check the appsscript.json file which can be accesed by going to Project Settings and toggling on the option Show the appsscripts.json file

about 4 years ago · Juan Pablo Isaza Relatório

0

The only reason could be the time zone setup of your script file. You can check out bi going to File > Project properties in the script editor.

Google developers docs

Also you can review this setting running this:

var timeZone = Session.getScriptTimeZone();
Logger.log(timeZone);
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