Skip to main content
3 de 6
Melhoria das palavras utilizadas na resposta
user avatar
user avatar

Por favor, veja se esse código resolve:

HTML:

<div class="input-group" id="DateDemo">
     <input type='text' id='weeklyDatePicker' placeholder="Select Week" />
</div>

JavaScript:

 $(document).ready(function(){
 
 $("#weeklyDatePicker").datetimepicker({
     format: 'DD-MM-YYYY'
 });
  
 $('#weeklyDatePicker').on('dp.change', function (e) {
     var value = $("#weeklyDatePicker").val();
     var firstDate = moment(value, "DD-MM-YYYY").day(0).format("DD-MM-YYYY");
     var lastDate =  moment(value, "DD-MM-YYYY").day(6).format("DD-MM-YYYY");
     $("#weeklyDatePicker").val(firstDate + " - " + lastDate);
 });
});
user167899