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

176
Views
Operations with dates in javascript

I hope you guys can help me. I'm developing a shopping page about online courses in Elementor. These courses start every 2 months and I want to add a feature that changes the price when there are only 19 or less days left to purchase the course before it starts. I managed to solve the problem only for certain cases, for example: The course begin on february 28th and todays date is february 17th. So by using the "new Date()" object and then adding the .getDate() method, I got the current day. Then, to grab the course date, I had to use the method parseInt("28th february"), (I'm Spanish so the number comes first). Once I had both dates I wrote an if statement saying:

if ((courseDate - currentDate) <= 19) { Do this... }

It works if boths dates are in the same month... But, for example, if the course begins the next month, on march 22th, it will also evaluate to true, but there are actually more than 19 days left to purchase... Any ideas about how can I solve it? I appriciate your help and time guys

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You want to work with the numeric values of dates, i.e., the number of milliseconds since 1 Jan 1970 at midnight. The relevant method is getTime().

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