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

139
Vistas
if statement with dates js

I have this:

let currentTime = new Date(customerid)
currentTime = currentTime.setDate(currentTime.getDate());
customerid = new Date(customerid)
currentTime = new Date(currentTime)

console.log(customerid)
console.log(currentTime)

if (customerid == currentTime) {
  res.redirect('/create-checkout-session')
} else {
  console.log("having to go into loading screen")
  res.redirect("/loadingscreen")
}

When i log what is happening:

 console.log(customerid)
 console.log(currentTime)

It returns this:

2022-02-13T00:00:00.000Z
2022-02-13T00:00:00.000Z

whcih I thought was fine, however, I then do the if statement logic, and it doesn't work, it goes into the else.

so when I do:

if (customerid == currentTime) {

it says it is not the same, although the output above shows that it is. Am i not able to do if logic with date paramaters? How should i fix this?

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