相关时间的日期和时间 [英] Date and time at relatime
本文介绍了相关时间的日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们如何实时获取计算机的日期和时间?
意思是,如果有人更改了计算机的日期和时间,我们如何在.net 2008中获取实际的日期和时间?
How can we get date and time of computer at realtime ?
Means, If someone changes date and time of computer, how can we get the actual date and time in .net 2008 ?
推荐答案
尝试此链接..
http://nickstips.wordpress.com/2010/02/12/c -get-nist-internet-time/ [
try this link..
http://nickstips.wordpress.com/2010/02/12/c-get-nist-internet-time/[^]
如果用户有权更改系统日期和时间,那么您将找不到简单的解决方案.您当然可以尝试检测是否进行了这样的更改,但这不会帮助您进行更正.
以下是您的问题的两种解决方案:
If the user has the right to change the systems date and time there is no easy solution for you. You could of course try to detect if such a change was made, but that will not help you in correcting it.
Here are two solutions to your problem:
- 如果计算机可以访问Internet,则可以使用此解决方案中建议的网络上的时间服务器和SNTP协议获取正确的日期和UTC时间: ^ ]
- 我接下来的最好的事情可以想到的是,这样做仍然比较困难,而且成本较高,因为这需要将硬件加密狗与您的软件捆绑在一起,其中包括一个计时机制(日历和时钟).
- If the computer has access to the internet you can get the correct date and UTC time using a timeserver on the net and the SNTP protocol as proposed in this solution: Simple Network Time (NTP) Protocol Client [^]
- The next best thing I could think of is still harder to do and also costlier as it would require bundling a hardware dongle with your software that would include a time keeping mechanism (Calendar & Clock).
希望有帮助,
曼弗雷德(Manfred)
Hope that helps,
Manfred
我不知道你在哪里遇到问题,
I don''t know where you are getting problem,
DateTime.Now
将返回当前系统的日期时间.
谢谢
--RA
will returns the current system datetime.
Thanks
--RA
这篇关于相关时间的日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文