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

179
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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