One solution will be to convert the string value of the initial date and time textboxes to an object Date
Javascript only and add one hour to its value. After that, just convert back to two strings and put the value in the final date and time textboxes. I snippeted, take a look.
function calculaDataHoraFinal() {
var valorDataIni = $("#data-ini").val();
var valorHoraIni = $("#hora-ini").val();
if (valorDataIni && valorHoraIni) {
var partesData = valorDataIni.split("/");
var partesHora = valorHoraIni.split(":");
var dataIni = new Date(partesData[2], partesData[1] - 1, partesData[0], partesHora[0], partesHora[1]);
var dataFim = new Date(dataIni.getTime());
dataFim.setHours(dataFim.getHours() + 1);
var partesHoraFim = dataFim.toTimeString().split(':');
$("#data-fim").val(dataFim.toLocaleDateString());
$("#hora-fim").val(partesHoraFim[0] + ':' + partesHoraFim[1]);
}
}
$("#data-ini, #hora-ini").on('change', calculaDataHoraFinal);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<input id="data-ini" type="text" />
<input id="hora-ini" type="text" /> até
<input id="data-fim" type="text" />
<input id="hora-fim" type="text" />
</div>
I know there are parse` methods of date as well as formatting, but they all depend on the browser location and the culture setting for these methods is not well implemented in all browsers. If you want to make things simpler, you can use a date handling library for Javascript like Moment js..
Missing you put the reference to the plugin Moment.js and Jquery. Your Jsfield does not work, but I fixed your code.
– Marconi