Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

155
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda