Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Currently I am using the following code to track my system time.
C#
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.
Posted

Use DateTime.UtcNow[^] property.
 
Share this answer
 
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/[^]
 
Share this answer
 
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..:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900