您好,我遇到了麻烦,我如何才能克服这个问题我搜索了一些文章,但提供的一些例子是在PHP。正如我上面的标题一样,我如何从PC2(Server side where I publish my project) (example of date and time is 8/12/2016 4:40 PM)获取Date and Time --以及我的PC1(client side who use the project) (example of date and time is 8/10/2016 5:00)的当前时间。我想要的是,我想在视图中将server side time显示到我的一个标签中。即使我操作/更改了PC1的日期和时间设置,标签也不会影响/更改,因为它来自PC2时间。我尝试使用Datetime.now()并尝试更改PC1中的设置时间,在刷新页面后,我的标签日期也会更改。
发布于 2016-08-12 17:31:21
您似乎正在使用Asp.net-Mvc,您希望在客户端浏览器上显示您的服务器时间。如果您使用的是Razor template engineer,请尝试以下操作:
<div>@Html.Label(DateTime.Now.ToString())</div>或者像这样:
<label for="">@DateTime.Now.ToString()</label>发布于 2016-08-12 16:52:17
DateTime dt = DateTime.Now;
String strDate="";
strDate = dt.ToString("MM/dd/yyyy hh:mm tt"); // 08/12/2016 02:22 PMhttps://stackoverflow.com/questions/38913643
复制相似问题