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

186
Vistas
How to format a date received from my server using javascript?

I need to format a date with javascript but I'm having a little trouble solving this.

I get two dates, I need to format them and then join the values. On one of the dates I get this:

"2022-07-12T04:00:00-0300"

And on the other date I get this:

"2022-07-12T06:00:00-0300"

These are always dynamic dates returned from my backend, but here on the frontend I need to display these two dates in this following format:

"04:00 - 06:00"
about 4 years ago · Santiago Gelvez
2 Respuestas
Responde la pregunta

0

You can use slice() method.

var date1 = "2022-07-12T04:00:00-0300";
var date2 = "2022-07-12T06:00:00-0300";

var formatted = `${date1.slice(11, 16)} - ${date2.slice(11, 16)}`;

console.log(formatted);

about 4 years ago · Santiago Gelvez Denunciar

0

This is assuming you only need the hours and minutes.

function datesToRange(start, end) {
  if (!start || !end) return ""; // If either date is null or undefined.
  return start.substring(12, 17) + " - " + end.substring(12, 17);
}

Now you can call this method to get the range in your required format.

E.g.

datesToRange("2022-07-12T04:00:00-0300", "2022-07-12T06:00:00-0300");

Will return "04:00 - 06:00".

about 4 years ago · Santiago Gelvez 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