-1

enter image description here

Now, Bootstrap datetimepicker viewed YYYY-DD-MM format.
But, I want only YYYY-DD format.

enter image description here

For example, Like the picture above.

Now Source.
Also it did not resolve to remove the DD to the source.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-md-3">
  <div class="col-md-5">
    <label style="margin-top: 8px;margin-left: 33px; white-space:nowrap;">datetimepicker</label>
  </div>
  <div class="col-md-7">
    <input class="form-control" type="text" name="daterange" value='<?php if(isset($_GET['to']) && $_GET['to'] != '') { echo @$_GET['to']." - ".@$_GET['from']; } ?>' />
  </div>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script>
$(function() {
        $('input[name="daterange"]').daterangepicker({
          <?php if(isset($_GET['to']) && $_GET['to'] != '') { ?>startDate:'<?php echo @$_GET['to']; ?>',<?php } ?>
          <?php if(isset($_GET['to']) && $_GET['to'] != '') { ?>endDate:'<?php echo @$_GET['from']; ?>',<?php } ?>
          timePicker: false,
          timePicker24Hour: false,
          format: 'YYYY-MM-DD'
        }, function(start, end)
        {
          location.href = "/Driving/drivingHistoryList?to="+start.format('YYYY-MM-DD')+"&from="+end.format('YYYY-MM-DD')+"<?php echo "&userid=".@$_GET['userid']."&carid=".@$_GET['carid']."&goal=".@$_GET['goal']."&order=".@$_GET['order']."&order_type=".@$_GET['order_type']."&page=".@$_GET['page']."&count=".@$_GET['count']; ?>";
        });
      });
</script>
F. Kim
  • 53
  • 1
  • 9

3 Answers3

3

Try this.

$('input[name="daterange"]').datepicker( {
    format: "mm-yyyy",
    viewMode: "months", 
    minViewMode: "months"
});
Aslam Patel
  • 874
  • 6
  • 19
2

Try this

$("#datepicker").datepicker( {
    format: "mm-yyyy" //  yyyy-mm
});

Bootstrap DatePicker format - bootstrap-datepicker.readthedocs.io

Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
1

Set 'viewMode' and 'format'. Try

$('input[name="daterange"]').datetimepicker({
      <?php if(isset($_GET['to']) && $_GET['to'] != '') { ?>startDate:'<?php echo @$_GET['to']; ?>',<?php } ?>
      <?php if(isset($_GET['to']) && $_GET['to'] != '') { ?>endDate:'<?php echo @$_GET['from']; ?>',<?php } ?>
      viewMode: 'years',
      format: 'MM/YYYY'
}
noufalcep
  • 3,446
  • 15
  • 33
  • 51