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

151
Views
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
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!