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

197
Vistas
how to display json date in timestamp format in html

I need to convert json date time to string and write it html table cell. Json I am getting is like this:

 "creation": {
        "date": {
            "year": 2022,
            "month": 1,
            "day": 9
        },
        "time": {
            "hour": 10,
            "minute": 14,
            "second": 11,
            "nano": 830000000
        }

I want to display it like this : 1-9-2022 10:14:11:83000000 Is there built-in function in JS. Your help appreciated

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

0

You can create your own function using template literals, check the doc https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

const creation = {
  date: {
      year: 2022,
      month: 1,
      day: 9
  },
  time: {
      hour: 10,
      minute: 14,
      second: 11,
      nano: 830000000
  }
}

const renderTimestanp = ({date, time}) => `${date.month}-${date.day}-${date.year} ${time.hour}:${time.minute}:${time.second}:${time.nano}`

// will return 1-9-2022 10:14:11:83000000
renderTimestanp(creation)

about 4 years ago · Juan Pablo Isaza Denunciar

0

There is no such build in function, but simple string concatenation will work:

var time = {
  "creation": {
    "date": {
      "year": 2022,
      "month": 1,
      "day": 9
    },
    "time": {
      "hour": 10,
      "minute": 14,
      "second": 11,
      "nano": 830000000
    }
  }
};

console.log(
  '' + time.creation.date.month + '-' + time.creation.date.day + '-' + time.creation.date.year +
  ' ' +
  time.creation.time.hour + ':' + time.creation.time.minute + ':' + time.creation.time.second + ':' + time.creation.time.nano
);

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