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

186
Vistas
Ejecutar función en un UTC específico +5:30 Hora una vez

Tengo una función principal(). Quiero ejecutar esta función a las 9:25, 1:25, 5:25 (considerando el tiempo de reloj de 12 horas, significa 9:30 de la mañana y de la noche). Cuando el reloj marca cualquiera de las horas mencionadas anteriormente, la función debería ejecutarse una vez. Entonces la función debería esperar a la próxima vez. La función similar se ejecuta a las 9:30 de la mañana (pero solo una vez y luego se detiene), luego debe esperar a la 1:25 de la tarde. Quiero que todo esto esté codificado en Javascript. ¿Hay algún planificador que me ayude...

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Haz algo como esto:

 var times = [[9, 25], [1, 25], [5, 25]]; var lastrun; function checktime(){ now = new Date(); // Get the current time if (lastrun != null){ if (now-lastrun > 60000) return; // Wait until a minute has elapsed // (In order to avoid the function running twice within the same minute) } ok = false; for (time of times){ // Iterate through target times target = new Date(); // Create a new date where the target time will be held target.setHours(time[0]); // Set the hour and minute to the target time target.setMinutes(time[1]); if (now.getTime() >= target.getTime()){ // Check if the target time has been reached ok = true; break; } } if (ok){ lastrun = now; // Store the time when the function was last run main(); // Run the main function if 'ok' is true } } setInterval(checktime, 1000);
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