如何获取实际日期而不是系统日期 [英] How to Get Real Date not System Date

查看:98
本文介绍了如何获取实际日期而不是系统日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨是否可以在没有任何互联网连接的情况下获得真实日期(非系统日期)?我用C#开发了我的应用程序。 DateTime.Now获取系统日期但我想知道实际日期,因为系统日期可能是错误的。有可能吗?怎么做?

Hi Is it possible to get real date (not system date) without any connection to internet? I developed my application by C#. DateTime.Now gets system date but I want to know real date because system date may be wrong. Is it possible?how to do this?

推荐答案

没有。您可以使用SNTP获取实际日期和时间(请参阅 [ ^ ]和这个 [ ^ ])与互联网连接。如果您具有计算机可以在具有Internet连接的计算机所在的网络连接,则可以将其用作客户端的SNTP服务器。否则,您将无法使用系统的日期/时间。
No. You can use SNTP to get the real date and time (see this[^] and this[^]) with an internet connection. If you have a network connection that the computer can use where a computer exists that does have an internet connection, then you can use that as an SNTP server for the client. Otherwise, you are stuck with the System''s date/time.


您好,



计算机知道我们设置了哪个在它上面,(如果我们为它设定一些日期,那么它显示相同);但如果它不知道日期那么它怎么能为你生成任何编程语言的日期。

例如。如果我把你放在黑暗的房间里几天没有任何小工具/通信(时钟)那么你能确定什么是实时或日期,对于计算机是相同的(如果你把错误的时钟初始化到计算机然后它会给你错误的时间)



你无法在没有设置电脑的情况下获得真实日期。



所以如果你能创造你的时钟那么你可以第一次设置真实日期,你将返回真正的日期时间。



谢谢。

请标记为ans。如果它对你有所帮助。
Hi,

The computer know which we set on it,(if we set some date for it, then it show the same); but if it didn''t know the date then how can It produce date for you for any programming language.
eg. If I put you in a dark room for several days without any gadget/communication(clock) then Can you identify what is real time or date, same for computer(if you Initialize wrong clock to computer then it return you wrong time)

you cant get real date without setting on your computer.

So If you can create your clock then you can set it first time with real date and you will returned always real date time.

Thank You.
Please mark as ans. if it helps you.


这篇关于如何获取实际日期而不是系统日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆