获取日期和时间. [英] to get date and time.

查看:84
本文介绍了获取日期和时间.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首次在我们的系统上安装操作系统时,尽管系统未连接到Internet,但仍会根据区域正确检测日期和时间.同样,也有可能用c#编写与程序相同的东西.我的意思是任何人都可以提供一个片段来根据该区域自动检测日期和时间.

While installing operating system on our system first time, the date and time will be detected correctly based on the region, though the system is not connected to the internet. In the same way is there any possibility to write the same thing as a program in c#. I mean can anybody provide a sniplet to detect the date and time automatically based on the region.

推荐答案

DateTime now = dateTime.Now;



假设将系统时钟设置为正确的本地时间和适当的时区,这应该是您所需要的.



Presuming your system clock is set for correct local time and the appropriate time zone, that should be all you need.


如果您尝试根据区域性获取日期和时间,请参见此处 [
If you are trying to get the date and time based on the culture, see here[^].


安装操作系统时,系统会从中获取日期和时间我认为是在制造过程中正确设置的计算机母板上的时钟.

就像JSOP所说的那样,您现在只需通过代码即可访问它.
When you installed the OS, it got the date and time from the clock on the mother board of the computer which, I assume, had been set correctly during manufacture.

As JSOP says, you can now just access it simply through code.


这篇关于获取日期和时间.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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