After the bootstrap-datapicker time by selecting event parameters passed to the called

Overview for the date control bootstrap-datapicker, and now want to get the value of the control, Quguan network to find API, that actually is not updated document, only to find stackflow.

Directly attached to the bar code

 

 

<li id="startTime" class="input-append date form_datetime">开始时间: <input  
                            size="20" type="text" value="" readonly> <span  
                            class="add-on calendarIcon"><i  
                                class="icon-calendar glyphicon glyphicon-th"></i></span>  
                        </li>  

 

Get the value:

 

method one:

$("#startTime").data("datepicker").getDate()  

Method Two:

$("#startTime").find("input").val();  

 

 

If you want to have a date formatting, you can do the following:

var date = $("#startTime").data("datepicker").getDate(),  

    formatted = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " " + date.getHours + ":" + date.getMinutes() + ":" + date.getSeconds();  

alert(formatted);  


Or input is provided directly tag  data-format

 

<input data-format="yyyy-MM-dd hh:mm:ss" type="text"></input>  

 

Published 25 original articles · won praise 10 · views 30000 +

Guess you like

Origin blog.csdn.net/xj932956499/article/details/79817478