I. The datetimebox OK button does not have an event to be clicked, but the onselect event can be used to simulate the "same effect as clicking the OK button". My code:
Key:
0. Understand the datetimebox control. This control is composed of the datebox + timespinner controls, and datebox inherits from the combo control.
1. Use the settext method to set the content of the control text box. This method is inherited from the combo control by datetimebox. The setvalue method cannot be used because it is inherited from datebox, but the datetimebox control does not override this method. Because datetimebox also contains "time, minute, and second", the datebox method cannot be used.
2. Use the spinner method to obtain the "time, minute, and second" information. This method returns the timespinner control contained in datetimebox. Use the getvalue method of the timespinner control to obtain the time information.
3. Use the onselect method to obtain the "date" information. onselect: function (date) {}, where date is the date selected when the event is triggered and is the date data of Js.
4. Use the hidepanel method to close the drop-down date panel. This method also inherits from the combo control.
Easy-to-understand code:
$ ('# Textstarttime'). datetimebox ({
Showseconds: false,
Required: True,
Onselect: function (date ){
VaR time = $ ('# textstarttime'). datetimebox ('json'). spinner ('getvalue ');
$ ('# Textstarttime '). datetimebox ('settext', date. getfullyear () + '-' + (date. getmonth () + 1) + '-' + date. getdate () + ''+ time );
$ ('# Textstarttime'). datetimebox ('hidemopanel ');
}
});
Let the code format be changed:
$ ('# Textstarttime'). datetimebox ({
Showseconds: false,
Required: True,
Onselect: function (date ){
VaR time = $ ('# textstarttime'). datetimebox ('json'). spinner ('getvalue ');
$ ('# Textstarttime'). datetimebox ('settext', date. getfullyear () + '-' + (date. getmonth () + 1) <10? ('0' + (date. getmonth () + 1): (date. getmonth () + 1) + '-' + (date. getdate () <10? ('0' + (date. getdate (): (date. getdate () + ''+ time );
$ ('# Textstarttime'). datetimebox ('hidemopanel ');
}
});
Ii. Date formatting
VaR sysformat = function (time, format ){
VaR T = new date (time );
VaR TF = function (I) {return (I <10? '0': '') + I };
Return format. Replace (/YYYY | mm | dd | HH | mm | SS/g, function (){
Switch (){
Case 'yyyy ':
Return TF (T. getfullyear ());
Break;
Case 'mm ':
Return TF (T. getmonth () + 1 );
Break;
Case 'mm ':
Return TF (T. getminutes ());
Break;
Case 'dd ':
Return TF (T. getdate ());
Break;
Case 'hh ':
Return TF (T. gethours ());
Break;
Case 'ss ':
Return TF (T. getseconds ());
Break;
}
})
}
Easyui datetimebox OK