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

120
Vistas
Google Apps Scripts Date conversions

I am populating a Google sheet with data from a JSON object I receive from Postman. Some of the information I receive is in this format:

{"attempt_starttime": "2021-09-21T03:28:13+0000",
 "attempt_endtime":"2021-09-21T03:28:35+0000",
 "invited_on":"2021-09-21T03:27:50+0000"}

I need to do some manipulations on them. What I want to know is

  1. How do I use an apps script to convert the data into a day of the week(Monday, Tuesday, etc.)
  2. How can I use apps script to do subtraction on the dates so I can get data like how long did it take the person to complete the task, how many days did it take to start the task after being invited, etc.

Thank you!

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

0

Adapt as you need ...

function chrono() {
  var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
  var jsonString = `{"attempt_starttime": "2021-09-21T03:28:13+0000",
 "attempt_endtime":"2021-09-21T03:28:35+0000",
 "invited_on":"2021-09-21T03:27:50+0000"}`
  var data = JSON.parse(jsonString)
  var startTime = new Date(data.attempt_starttime)
  var endTime = new Date(data.attempt_endtime)
  var invitedTime = new Date(data.invited_on)
  console.log(startTime + ' ... ' + days[startTime.getDay()])
  console.log(endTime + ' ... ' + days[endTime.getDay()])
  console.log(invitedTime + ' ... ' + days[invitedTime.getDay()])

  console.log(invitedTime.getUTCHours()); 
  console.log(invitedTime.getUTCMinutes());
  console.log(invitedTime.getUTCSeconds());

  console.log((startTime-invitedTime)/1000 + ' secondes')
  console.log((endTime-startTime)/1000 + ' secondes')
}
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