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

80
Vistas
Date variable showing different time

I have a very simple JavaScript code:

class Person {
  constructor(firstName, lastName, dateOfBirth) {
    this.firstName = firstName;
    this.lastName = lastName;
    this.dateOfBirth = dateOfBirth;
  }
}

let person1 = new Person('John', 'Doe', new Date(1993, 4, 5, 18, 30, 0));
let person2 = new Person('Hannah', 'Universe', new Date(1967, 10, 28, 2, 30, 0));

console.log(person1);
console.log(person2);

The output of this is:

Person {
  firstName: 'John',
  lastName: 'Doe',
  dateOfBirth: 1993-05-05T16:30:00.000Z
}
Person {
  firstName: 'Hana',
  lastName: 'Universe',
  dateOfBirth: 1967-11-28T01:30:00.000Z
}

How can the person1 time be 16:30 if I specified 18:30 in the constructor, and a the same time person2 has 01:30 and I specified 02:30 in the constructor? The person1 difference between input and output is 2 hours, person2 difference between input and output is 1 hour. How is that possible?

about 4 years ago · Juan Pablo Isaza
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