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

90
Views
Subtraction of days on DateObjects in JavaScript is not working (as expected)

Can someone please tell me why the console logs untilDate Mon Mar 14 2022 here when it should log untilDate Thu Dec 14 2021

let _untilDate = new Date(); // Mon Mar 14 2022
let _fromDate = new Date(); // Mon Mar 14 2022

_fromDate.setDate(_untilDate.getDate() - 89);
///_fromDate should now be Wed Dec 15 2021
_untilDate.setDate(_fromDate.getDate() - 1);
///_untilDate should now be Thu Dec 14 2021
console.log(`untilDate: ${_untilDate.toDateString()}`);
//actually logs untilDate Mon Mar 14 2022
console.log(`fromDate: ${_fromDate.toDateString()}`);

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!