如何使用ASP.Net C#获取全球时间 [英] How to get global time using ASP.Net C#
本文介绍了如何使用ASP.Net C#获取全球时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前我正在使用以下代码来跟踪我的系统时间。
Currently I am using the following code to track my system time.
int spendMinute, spendSecond;
DateTime currentTime = DateTime.Now;
spendMinute = currentTime.Minute;
spendSecond = currentTime.Second;
但是我想要一些可以获得当前全球时间的东西,即任何系统更改的时间都不会改变。
But I want something by which I can get the current global time, that is the time will not change for any system change.
推荐答案
使用 DateTime.UtcNow [ ^ ]属性。
ZoltánZörgő的回答是正确的。
如果您想从当地时间转换到UTC(反之亦然),请查看本文。
http://codingstill.com / 2010/10 / manage-date-in-net / [ ^ ]
Zoltán Zörgő's answer is correct.
If you want to make conversions from local time to UTC (or vice versa), you check this article.
http://codingstill.com/2010/10/managing-dates-in-net/[^]
DateTime.Now
如果我访问你的话,我不会给你系统时间应用程序,即如果我在上午11:00访问您的应用程序,如果它根据服务器时间下午3:00访问您的服务器,而不是我的。
我不知道你的意思是全球时间,但你可以参考这个链接
服务器上的DateTime.Now问题 [ ^ ]
问候..:)
DateTime.Now
will not give you my system time if i access your application,that is if i access your app at 11:00 AM and if its 3:00 PM according to server time than you will get server one,not mine.
I don't know what you mean by Global time but you can refer to this link
Problem with DateTime.Now on Server[^]
Regards..:)
这篇关于如何使用ASP.Net C#获取全球时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文