1
Dae galera, with a little problem here, I have the following function:
function atualizaHoraServidor() {
var dispTime = formatarData(digital);
$('#horarioServidor .horarioRelogio').text(dispTime);
digital.setSeconds(digital.getSeconds() + 1);
setTimeout("atualizaHoraServidor()", 1000);
}
function formatarData(data) {
var options = {
year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: '2-digit'
};
return data.toLocaleDateString('pt-br', options);
}
The variable digital
is created with the following script:
<script type="text/javascript"> var digital = new Date(<?php echo str_replace(':',', ', str_replace('/',', ', str_replace(' ',', ', date('Y/m/d H:i:s')))).', 0'; ?>); </script>
What is happening is that it is showing the date with 1 month in advance, thus: 03/02/2017 11:45:55
Does anyone know how I can correct that mistake?
I’ve checked the server time and it’s correct.
Where does the variable come from
digital
informatarData(digital);
. Furthermore, javascript works for0
until11
being0
january and11
december.– Gabriel Heming
Comes from a script in the header:
<script type="text/javascript"> var digital = new Date(<?php echo str_replace(':',', ', str_replace('/',', ', str_replace(' ',', ', date('Y/m/d H:i:s')))).', 0'; ?>); </script>
– Wendler