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

172
Vistas
API Response Date Format

I'm using Google Apps Script making an API request to get a date. The date, however, is coming back as a number in scientific notation (1.635218706E9) which I'm assuming is in the format of milliseconds from 1970. After converting it from scientific notation to a regular number (1635218706) creating a new javascript date with it the wrong date and year. It should be Oct 25 2021, but instead gives Dec 31 1969.

Am I missing something when creating a new date from the number? And is there a way just have the API respond with a more readable date instead of milliseconds from 1970?

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

0

Just in case. I found if you multiply this number by 1000 and feed it to Data object you can get something a little bit more reasonable:

var seconds = 1.635218706E9;
var date = new Date(seconds*1000);
console.log(date); // output: 2021-10-26T03:25:06.000Z

var date_str = [date.getFullYear(), date.getMonth()+1, date.getDate()].join('/')
console.log(date_str); // output: 2021/10/26

It looks like the API gives you seconds.

about 4 years ago · Juan Pablo Isaza Denunciar

0

you can use toLocaleString / toLocaleDateString

so the code is like this

const dates = new Date()
const fullDates = dates.toLocaleString('en-US')

you can read in documentation here : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString

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