0
Hey, guys, you okay? See if you can help me, I have 3 inputs, one of them put the date the employee entered and the other the date the employee was disconnected. The 3° input shows the home time, but is inserting 4 numbers zero after the result, I’m trying to treat/remove them with Math.floor but it’s not working. Can you help me?
$('#desligamento').focusout(function(){
var x = document.getElementById('admissao').value.replace(/[^\d]+/g,'');
var y = document.getElementById('desligamento').value.replace(/[^\d]+/g,'');
var z = Math.floor(document.getElementById('resultado').value = y - x);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="date" id="admissao" placeholder="Admissao">
<input type="date" id="desligamento" placeholder="Desligamento">
<input type="text" id="resultado" placeholder="Tempo trabalhado" disabled>
Are you sure? because running by stackoverflow is correct
– Everton Neri
So dear Everton, have you noticed that the result is exorbitant? I need to remove this excess of zeros and leave only the first 2 numbers.
– Renato Oliveira
Here the result is coming out right. No excesses.
– Gato de Schrödinger
I don’t want to insist but you could send me the print?
– Renato Oliveira
A guess: when you say that the script is entering four numbers after the result, you are putting a date with a difference of one year and your expectation is to get the result in years. Now, colleagues who say that the result is correct, are probably testing a difference of days and are waiting for the result in days. Well, if my guess is correct, the problem with your script is a question of testing. You need to test with more values.
– user142154