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

162
Views
Typescript gives ridiculous wrong year in new Date() function

I am really pulling my hair now and going crazy:

  const {year, month} = req.headers;
  const date_range_from = new Date(year, month, 1);  
  const date_range_to = new Date(year, month + 1, 1); // wrong year; why?   
  
  console.log("year, month: ", year, month)
  console.log("date_range_from, date_range_to: ", date_range_from, date_range_to)

The console log gives:

year, month:  2021 6
date_range_from, date_range_to:  2021-06-30T15:00:00.000Z 2026-01-31T15:00:00.000Z

WHY 2026 ???? What is going on???

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!