4
I have the code below, which displays a clock on a page, which serves to record factory intervals. It works perfectly, with the code below:
function moveRelogio(){
momentoAtual = new Date();
hora = momentoAtual.getHours();
if (hora < 10) {
hora = '0' + hora;
} else {
hora = hora + '';
}
minuto = momentoAtual.getMinutes();
if (minuto < 10) {
minuto = '0' + minuto;
} else {
minuto = minuto + '';
}
segundo = momentoAtual.getSeconds();
if (segundo < 10) {
segundo = '0' + segundo;
} else {
segundo = segundo + '';
}
horaImprimivel = hora + ":" + minuto + ":" + segundo
document.cadastro.hora_inicio.value = horaImprimivel;
setTimeout("moveRelogio()",1000);
}
Eventually the time displayed is not the same registered, because for registration is used the time of the AD. User can not change it as PI are used without keyboard and mouse.
Is there any way with Javascript to get the time of a server or the internet, from an NTP?
Great answer Renan. But as I did not have time to change much the current structure of the code, I ended up finding another way. I will post it below, based on the question code. Anyway, +1. Thank you.
– Diego