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

155
Views
how to check for yesterday date in javascript? Without doing one by one validation

How can I check the yesterday date without doing one by one validation. I am storing data in session and try to fetch the data if current date is changed, (with date, month and year). I can do this by checking one by one but is their any simple way to do this.

Process is like this :

  1. user open the website (An api call make to the server and get the data and saved that data into localstorage)

  2. If user refresh the website all is working fine, bcoz I can fetch the data from localhost

  3. But from the admin side I add new data, now If user open the website it will get the old data not the new one,

So I am trying to check if 24 hours has been passed then a new API call make to the server and get the fresh data.

It will reduce the api calls in a sinlge daya as well as make the website more faster.

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

0

You could compare now's date to 24 hours ago using the javascript Date object

var yourDate = new Date('02.08.2021 05:31');
var timeStamp = Math.round(new Date().getTime() / 1000);
var yesterdayTimeStamp = timeStamp - (24 * 3600);
var isLessThen24Hours = yourDate >= new Date(yesterdayTimeStamp * 1000).getTime();

console.log("is less then 24 hours = " + isLessThen24Hours);

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!