获取计时器并从客户端设置系统时间服务器? [英] Get the timer and set the system time Server from the client ?
本文介绍了获取计时器并从客户端设置系统时间服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有2台计算机,美国的服务器,客户端在法国的客户端可以获得时间并重置服务器系统时间吗?如何编写代码?
Assuming I have 2 computers, server in USA, client in France from client can I get time and reset server system time? how to write code ?
推荐答案
你好,
对于迟到的回复感到抱歉。
Sorry for the late reply.
如果客户端和服务器位于不同的时区,则需要获取UTC时间,然后将其转换为本地时间:
If the client and server are in different time zones, you need to get UTC time then convert it to local time:
//Get UTC time
var utcTime = DateTime.UtcNow;
Console.WriteLine("{0} {1}", utcTime, utcTime.Kind);
//Convert UTC time to local time
var localTime = utcTime.ToLocalTime();
Console.WriteLine("{0} {1}", localTime, localTime.Kind);
我发现有些问题与您类似,请参考以下内容:
I found there are some questions similar to you, please refer to them as below:
How to deal with difference in timezones from server and client
希望这些帮助!
问候,
Frankie
这篇关于获取计时器并从客户端设置系统时间服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文