[英]how to get the date and time in from PC2 to PC1?
您好,我在解決一些問題時遇到了麻煩,但是我在PHP
提供了一些示例。 作為我上面的標題,我如何從PC2(Server side where I publish my project)
獲取Date and Time
(example of date and time is 8/12/2016 4:40 PM)
以及PC1(client side who use the project)
的當前時間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
更改設置時間,並且刷新頁面后我的標簽日期也更改了。
DateTime dt = DateTime.Now;
String strDate="";
strDate = dt.ToString("MM/dd/yyyy hh:mm tt"); // 08/12/2016 02:22 PM
似乎您正在使用Asp.net-Mvc,您想向客戶端瀏覽器顯示服務器時間。 如果您使用的是Razor模板工程師,請嘗試以下操作:
<div>@Html.Label(DateTime.Now.ToString())</div>
或像這樣:
<label for="">@DateTime.Now.ToString()</label>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.