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

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

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