Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

73
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!