我有两个带有德语格式日期的字段。如何添加可变的月数到 date2,我使用 Pikaday。温我更改 datepicker1 然后它应该 datepicker2 = datepicker2 + addedMonth
<label for="bis">bis</label>
<input type="text" name="bis" id="datepicker1" value="<?php echo date("d.m.Y", strtotime($bis)); ?>" onchange="updateDate(this.value, <?php echo $addedMonth; ?>)">
<?php
$geprueft_bis ="22.04.2016";
$pruefen_wann ="22.10.2016";
$addedMonth=6;
?>
<script>
function updateDate(val, intervall) {
p = document.getElementById("datepicker1").value;
newp = val+intervall;
document.getElementById("datepicker2").value = newp;
}
</script>
<label for="bis">bis</label>
<input type="text" name="bis" id="datepicker1" value="<?php echo date("d.m.Y", strtotime($bis)); ?>" onchange="updateDate(this.value, <?php echo $addedMonth; ?>)">
<label for="wann">pruefen wann</label>
<input type="text" name="wann" id="datepicker2" value="<?php echo date("d.m.Y", strtotime($wann)); ?>">
<script src="moment.js"></script>
<script src="pikaday.js"></script>
<script>
var picker = new Pikaday({
field: document.getElementById('datepicker1'),
format: 'DD.MM.YYYY',
onSelect: function() {
console.log(this.getMoment().format('Do MMMM YYYY'));
}
});
var picker = new Pikaday({
field: document.getElementById('datepicker2'),
format: 'DD.MM.YYYY',
onSelect: function() {
console.log(this.getMoment().format('Do MMMM YYYY'));
}
});
</script>