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

118
Vistas
input "datetime-local" > js code that makes the seconds run/move accurately for time to update

I would like to find out how to have the seconds run/move accurately for the time to change. is there a way I can do that with the js script that I have provided below?

thank you all.

functionName(); //First execution
 setInterval(functionName, 1000); //Ask the browser to execute functionName as soon as possible after 1 second has passed

function functionName(){
   var now = new Date();
   now.setMinutes(now.getMinutes() - now.getTimezoneOffset());
   document.getElementById('dt').value = now.toISOString().slice(0,16);
}
<input readonly="readonly" name="dt" id="dt" type="datetime-local" step="1" />

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

Using getSeconds and setSeconds works:

I also changed the string slice to .slice(0,19) to show the updated seconds.

functionName(); //First execution
 setInterval(functionName, 1000); //Ask the browser to execute functionName as soon as possible after 1 second has passed

function functionName(){
   var now = new Date();
   now.setSeconds(now.getSeconds() - now.getTimezoneOffset());
   document.getElementById('dt').value = now.toISOString().slice(0,19);
}
<input readonly="readonly" name="dt" id="dt" type="datetime-local" step="1" />

about 4 years ago · Santiago Gelvez 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