BOOTSTRAP3 DateTimePicker Controls use instances _javascript tips

Source: Internet
Author: User
Tags locale

BOOTSTRAP3 Date + Time selection control method of use for your reference, the specific contents are as follows

1. Support date selection, format setting
2. Support Time Selection
3. Support Time Segment selection control
4. Support Chinese

Website address: http://eonasdan.github.io/bootstrap-datetimepicker/
Git address: Https://github.com/Eonasdan/bootstrap-datetimepicker
Moment language Pack: Https://github.com/moment/moment
DateTimePicker Usage Configuration instructions: http://eonasdan.github.io/bootstrap-datetimepicker/Options/
Moment time Format usage instructions: http://momentjs.com/docs/

Using the method, the referenced file:

<script src= ". /js/jquery-1.11.3.min.js "></script> 
<link href=". /js/bootstrap-3.3.5-dist/css/bootstrap.css "rel=" stylesheet "/> 
<script src=". /js/bootstrap-3.3.5-dist/js/bootstrap.min.js "></script> 
 
<link href=". /js/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css "rel=" stylesheet "/> 
<script src=". /js/bootstrap-datetimepicker/js/moment-with-locales.min.js "></script> 
<script src=". /js/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js "></script> 

Example 1, simple configuration:

 <div class= "Row" > <div class= ' col-sm-6 ' > <div class= ' form-group ' > <label> Select Date:</label> <!--specify date tag--> <div class= ' input-group date ' id= ' dateTimePicker1 ' 
  ; <input type= ' text ' class= "Form-control"/> <span class= "Input-group-addon" > <span class= "Glyphicon g Lyphicon-calendar "></span> </span> </div> </div> </div> <div class= ' col-sm -6 ' > <div class= "form-group" > <label> Select Date + Time:</label> <!--specify date tag--> <div class = ' Input-group date ' id= ' Datetimepicker2 ' > <input type= ' text ' class= ' Form-control '/> <span the class= ' input- Group-addon "> <span class=" Glyphicon glyphicon-calendar "></span> </span> </div> ;/div> </div> </div> 

$ (' #datetimepicker1 '). DateTimePicker ({ format: ' Yyyy-mm-dd ', locale:moment.locale (' ZH-CN ') }); $ (' #datetimepicker2 '). DateTimePicker ({ format: ' Yyyy-mm-dd hh:mm ', locale:moment.locale (' ZH-CN ') });

Instance 2, select a time period:

 <div class= "Row" > <div class= ' col-sm-6 ' > <div class= ' form-group ' > <label> Select Start Time:</label> <!--specify a date tag--> <div class= ' input-group date ' id= ' dateTimePicker1 ' & 
  Gt <input type= ' text ' class= "Form-control"/> <span class= "Input-group-addon" > <span class= "Glyphicon g Lyphicon-calendar "></span> </span> </div> </div> </div> <div class= ' col-sm -6 ' > <div class= "form-group" > <label> Select End Time:</label> <!--specify a date tag--> <div class= ' Input-group date ' id= ' Datetimepicker2 ' > <input type= ' text ' class= ' Form-control '/> <span the class= ' input-g Roup-addon "> <span class=" Glyphicon glyphicon-calendar "></span> </span> </div> < /div> </div> </div> 
$ (function () { 
 var picker1 = $ (' #datetimepicker1 '). DateTimePicker ({ 
 format: ' Yyyy-mm-dd ', 
 locale: Moment.locale (' ZH-CN '), 
 //mindate: ' 2016-7-1 ' 
 }); 
 var picker2 = $ (' #datetimepicker2 '). DateTimePicker ({ 
 format: ' Yyyy-mm-dd ', 
 locale:moment.locale (' ZH-CN ') 
 }); 
 Dynamically set minimum value 
 picker1.on (' Dp.change ', function (e) { 
 picker2.data (' DateTimePicker '). MinDate (e.date); 
 }); 
 Dynamically set maximum value 
 picker2.on (' Dp.change ', function (e) { 
 picker1.data (' DateTimePicker '). MaxDate (e.date); 
 }); 
}); 

If you want to further study, you can click here to learn, and then attach 3 wonderful topics:

Bootstrap Learning Course

Bootstrap Practical Course

Bootstrap Table Use Tutorial

Bootstrap Plugin Usage Tutorial

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.