如何在asp.net中的日期选择器控件中将客户端时间与服务器时间匹配

乔乔

我两个text boxes都有date_picker控制权。第一种方法text box是在加载页面时自动填充日期和时间,第二种方法text box是使用服务器的Date-time;第二种方法是用户必须选择日期时间,但它占用系统时间,并且不匹配。

我想在用户选择日期时间时将其自动转换为服务器时间。这怎么可能?谁能说我?

djroedger

您要查找服务器的时间,但要查找用户的选择日期吗?如果是这样,请考虑以下事项:

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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在Firebase中的服务器和客户端之间使时间戳相同?

在ASP.NET服务器端还是客户端中的HTML控件?

如何进行客户端系统时间和Internet服务器上的日期时间之间的时间比较(实际本地时间)

ASP.NET服务器端或客户端的验证控件?

如何在html元素中呈现服务器控件客户端ID

如何从服务器获取日期和时间并像使用客户端一样使用它?

如何在ASP.NET Web应用程序中的服务器和客户端之间进行通信?

在ASP.NET Core SignalR中,如何从服务器向客户端发送消息?

如何在日期选择器日历中添加时间?

服务器如何在服务器/客户端拓扑中检测客户端电源关闭

如何在客户端中存储Web服务器的多个服务器地址?

如何在js中将js中的变量从服务器端传递到客户端

如何在 html 模板 (ASP.NET) 中的 Javascript 饼图中使用 AJAX 方法显示从客户端检索的动态服务器端数据

如何使用asp.net访问服务器端的客户端文件

如何在反应日期时间范围选择器中清除选定的日期时间?

服务器如何与 RAFT 中的客户端通信?

服务器如何在基于令牌的授权中将 JWT 发送到客户端?

如何在Google Earth Engine中将值从服务器复制到客户端?

如何在Meteor中将数据从服务器传递到客户端

如何在Node.js中将文件从服务器发送到客户端

如何在Meteor中将数据从客户端发送到服务器?

如何在python中将图片从服务器发送到客户端

如何在Node / Express中将JS从客户端移动到服务器?

在ASP.net MVC Signal R中连接客户端服务器

如何在颤抖的默认日期选择器中删除时间戳或仅获取日期形式的日期选择器?

如何在客户端 nextjs 中更改服务器端变量

如何在OpenVPN中与服务器端共享客户端Internet连接?

在客户端上从客户端ASP.NET调用服务器端方法

jQuery选择了多个选择,如何在asp.net中获取选择值服务器端?