1. 程式人生 > >Bootstrap日期外掛線上使用,引入即可

Bootstrap日期外掛線上使用,引入即可

引入部分

<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>  

<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> 
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
<script src="https://cdn.bootcss.com/moment.js/2.18.1/moment-with-locales.min.js"></script>  
<link href="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css" rel="stylesheet" />

<script src="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>  

HTML部分   

   <label for="">選擇日期:</label> 

          <div class="input-group date" id='date1'>  

                <input type="text" class="form-control" />  

                <span class="input-group-addon">  
                    <i class="glyphicon glyphicon-calendar"></i>  
                </span>  
            </div>  

<script>

$('#date1').datetimepicker({  

    format: 'YYYY-MM-DD hh:mm:ss',  
    locale: moment.locale('zh-cn')  
});
 </script>