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

146
Vistas
use epoch with current date

I have this:

let today = new Date()
let todayMinusFive = today.setHours(today.getHours() - 5);

it is taking the current time and then subtract 5 hours from it to get the time in EST. logging this will get me an epoch time.

then what i am doing is this:

let myTime = new Date(today.getFullYear(), today.getMonth(), today.getDay(), hour, minute);

and what this does is take the current date with my variables of hour and minute defined in there, which are properly split above. After this, I do this:

myTime = Math.floor(myTime / 1000)

this again now gives me the epoch time for my time from the database with hour and minute.

What I then want to do is subtract the two:

if (todayMinusFive - myTime <= 5) {
 console.log("doing logic")
}

but the problem is it isn't working. i know for a fact that the time difference is less then 5, and it is saying it is this huge number like 16000 or something. What am i doing wrong?

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