Tag: CTI for HTML Io Code Time
1. HTML code:
<Input id = "txtbegintime" class = "easyui-datebox" data-Options = "formatter: myformatter, Parser: myparser"> </input> <B> -- </B>
<Input id = "txtendtime" class = "easyui-datebox" data-Options = "formatter: myformatter, Parser: myparser"> </input>
2. js code:
Function myformatter (date ){
Var y = date. getfullyear ();
VaR M = date. getmonth () + 1;
VaR d = date. getdate ();
Return y + '-' + (M <10? ('0' + M): m) + '-' + (d <10? ('0' + d): d );
}
Function myparser (s ){
If (! S) return new date ();
VaR Ss = (S. Split ('-'));
Var y = parseint (ss [0], 10 );
VaR M = parseint (ss [1], 10 );
VaR d = parseint (ss [2], 10 );
If (! Isnan (y )&&! Isnan (m )&&! Isnan (D )){
Return new date (m-1, d );
} Else {
Return new date ();
}
}
// Page loading
$ (Function (){
// Set the time
VaR curr_time = new date ();
$ ("# Txtbegintime"). datebox ("setvalue", myformatter (curr_time ));
$ ("# Txtendtime"). datebox ("setvalue", myformatter (curr_time ));
// Obtain the time
VaR begintime = $ ("# txtbegintime"). datebox ("getvalue ");
VaR endtime = $ ("# txtendtime"). datebox ("getvalue ");
});