Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable time in bootstrap date time picker

I am using bootstrap date time picker in my web application, made in PHP/HTML5 and JavaScript. I am currently using one from here: http://tarruda.github.io/bootstrap-datetimepicker/

When I am using the control without time, it doesn't work. It just shows a blank text box.

I just want to remove time from date time picker. Is there any solution for this?

<div class="well">     <div id="datetimepicker4" class="input-append">          <input data-format="yyyy-MM-dd" type="text"></input>          <span class="add-on">              <i data-time-icon="icon-time" data-date-icon="icon-calendar"> </i>          </span>      </div>  </div>  <script type="text/javascript">      $(function() {          $('#datetimepicker4').datetimepicker({ pickTime: false });      });  </script> 
like image 598
Chirag Sudra Avatar asked Apr 17 '14 15:04

Chirag Sudra


People also ask

How do I hide the time on my date picker?

One more solution for the mentioned use-case is to define type property to "date" in the DateTime type Input widget Attributes section as shown below, it will hide the time value in the respective DateTime input field. Hope this helps you!

How do I use bootstrap time Picker?

You can use Time Picker and Date Picker together as a one component. If you want to do this, you have to use input with . date-time class. You have to use also data-open="DatePickerID" HTML data-* Attribute and .

How do I change the datepicker format in bootstrap?

In order to set the date format, we only need to add format of one argument and then we will add our required format, which is shown in the following example: Example 1: In this example, we are going to use dd-mm-yyyy format.

Why doesn't bootstrap DateTimePicker let me choose a time?

For v4: Bootstrap Datetimepicker now uses the format to determine if a time-component is present. If no time component is present, it won't let you choose a time (and hide the clock icon). Why was this voted down? This is the only answer that correctly explains that the plugin's option have changed in the latest version.

How to change DateTimePicker to datepicker?

There are sample folders each with an index.html. I know this is late, but the answer is simply removing "time" from the word, datetimepicker to change it to datepicker. You can format it with dateFormat.

Why is the clock icon removed from my DateTimePicker?

The behaviour described applies to Eonasdan's datetimepicker v3, v4. If you are using the latest (which you should), then not having a time component in the format will automatically remove the clock icon. And please don't post the same comment to multiple answers... It suggests a lack of motivation...

How to add a second string with different date formatting using bootstrap?

Using a Bootstrap datepicker and the getDate method to add a second string with different date formatting. Compatible browsers: Chrome, Edge, Firefox, Opera, Safari Dependencies: bootstrap-datepicker.css, bootstrap-datepicker.js, jquery.js, jquery-dateFormat.js An accessible and Bootstrap compatible datepicker.


1 Answers

Check the below snippet

<div class="container"> <div class="row">     <div class='col-sm-6'>         <div class="form-group">             <div class='input-group date' id='datetimepicker4'>                 <input type='text' class="form-control" />                 <span class="input-group-addon"><span class="glyphicon glyphicon-time"></span>                 </span>             </div>         </div>     </div>     <script type="text/javascript">         $(function() {                          // Bootstrap DateTimePicker v4            $('#datetimepicker4').datetimepicker({                  format: 'DD/MM/YYYY'            });         });           </script> </div> 

You can refer http://eonasdan.github.io/bootstrap-datetimepicker/ for documentation and other functions in detail. This should work.

Update to support i18n

Use localized formats of moment.js:

  • L for date only
  • LT for time only
  • L LT for date and time

See other localized formats in the moment.js documentation (https://momentjs.com/docs/#/displaying/format/)

like image 167
Ck Maurya Avatar answered Sep 20 '22 19:09

Ck Maurya