我两个text boxes
都有date_picker
控制权。第一种方法text box
是在加载页面时自动填充日期和时间,第二种方法text box
是使用服务器的Date-time;第二种方法是用户必须选择日期时间,但它占用系统时间,并且不匹配。
我想在用户选择日期时间时将其自动转换为服务器时间。这怎么可能?谁能说我?
您要查找服务器的时间,但要查找用户的选择日期吗?如果是这样,请考虑以下事项:
C#
DateTime ServerDateTime = new DateTime();
ServerDateTime = DateTime.Now;
DateTime ClientDate = clientDateControl.Value;
DateTime AdjustedDateTime = new DateTime(ClientDate.Year, ClientDate.Month, ClientDate.Day, ServerDateTime.Hour, ServerDateTime.Minute, ServerDateTime.Second);
VB
Dim ServerDateTime As DateTime = New DateTime()
ServerDateTime = DateTime.Now
Dim ClientDate As DateTime = clientDateControl.Value
Dim AdjustedDateTime As DateTime = New DateTime(ClientDate.Year, ClientDate.Month, ClientDate.Day, ServerDateTime.Hour, ServerDateTime.Minute, ServerDateTime.Second)
使用此方法,您可以继续使用第二个日期选择器控件,并将其值替换为ServerDateTime变量,或者可以删除第二个日期选择器控件,因为您已经知道服务器日期时间服务器端。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句