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

188
Vistas
Google Scripts "Utilities.formatDate" does nothing with the time zone parameter

This 2 lines generate the same output:

Logger.log(Utilities.formatDate(new Date(), "ET", "yyyy-MM-dd'T'HH:mm:ss'Z'"));
Logger.log(Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd'T'HH:mm:ss'Z'"));

Output:

2:20:37 PM Info -> 2022-01-26T19:20:37Z
2:20:37 PM Info -> 2022-01-26T19:20:37Z

Doesn't matter the input, is always converting the date to UTC (probably), this makes impossible to print the correct date and time.

What is the correct way to format a date-time in Google Scripts?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

"ET" is not an accepted time zone name.

For that you would use 'America/New_York'.

Apps Script's documentation doesn't call that out, which can be frustrating to non-developers. Here is the list of all the timeZone ids

Also, by putting the '' around the Z, it treats it as a string and just returns the date with a Z. I know that is what is in the example on the apps script page, but it is wrong.

Try this:

Logger.log(Utilities.formatDate(new Date(), "America/New_York", "yyyy-MM-dd'T'HH:mm:ss z"));
Logger.log(Utilities.formatDate(new Date(), "America/New_York", "yyyy-MM-dd'T'HH:mm:ss Z"));
Logger.log(Utilities.formatDate(new Date(), "America/Los_Angeles", "yyyy-MM-dd'T'HH:mm:ss z"));
Logger.log(Utilities.formatDate(new Date(), "America/Los_Angeles", "yyyy-MM-dd'T'HH:mm:ss Z"));
Logger.log(Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd'T'HH:mm:ss Z"));
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