Moh
Moh

Reputation: 39

How to disable pickTime bootstrap dateTimePicker

I want to disable the time choice with bootstrap-datetimepicker.

This is my JavaScript:

$('.dateTimePicker2').datetimepicker({
    language: "fr",
    pickTime: false,
});

I know that there are different datetimepicker plugins. I use smalot/bootstrap-datetimepicker. Even if I set pickTime to false, it doesn't work? Any idea?

Upvotes: 2

Views: 2981

Answers (1)

VincenzoC
VincenzoC

Reputation: 31502

You can use format and minView option, setting format: "yyyy-mm-dd" and minView: "month". The format option determines the format to show in the input while the minView option is the lowest view that the datetimepicker should show.

Here a working sample:

$('.dateTimePicker2').datetimepicker({
    format: "yyyy-mm-dd",
    minView: "month",
    language: "fr"
});
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/smalot-bootstrap-datetimepicker/2.4.4/css/bootstrap-datetimepicker.min.css" rel="stylesheet"/>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/smalot-bootstrap-datetimepicker/2.4.4/js/bootstrap-datetimepicker.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/smalot-bootstrap-datetimepicker/2.4.4/js/locales/bootstrap-datetimepicker.fr.js"></script>

<input size="16" type="text" readonly class="dateTimePicker2">

Upvotes: 2

Related Questions