2

我正在开发一个带有预订引擎的应用程序。所以基本上我需要一个来自互联网的日期。

System.DateTime.Now

我已经使用了它,但它返回给我当前(本地)系统日期。我不想要系统日期,因为它可以在客户端更改。所以我正在寻找互联网(UTC)日期。

4

3 回答 3

0

In ASP.Net System.DateTime.Now returns the time of the server, not the client. This has no bearing to the date and time on a clients computer.

If you really want to get the date from a different server, try this.

于 2013-01-11T07:06:31.313 回答
0

你为什么不使用

DateTime.UtcNow 

这将为您提供当前的 UTC 日期,然后您可以通过向其添加小时数来更改不同时区的日期,或者可以将其用作标准日期。

于 2013-01-11T07:24:04.050 回答
-1

使用 javascript 获取日期并将其存储在隐藏字段中。

document.getElementById("hdnTime").value = new Date();

然后从服务器端的隐藏变量中获取客户端日期。

于 2013-01-11T07:10:43.957 回答