Getting current GMT time
Is there a method in C# that returns the UTC (GMT) time zone? Not based on the system's time.
Basically I want to get the correct UTC time even if my system time is not right.
Instead of calling
DateTime.Now.ToUniversalTime()
you can call
DateTime.UtcNow
Same thing but shorter :) Documentation here.
Not based on the system's time? You'd need to make a call to a network time service or something similar. You could write an NTP client, or just screenscrape World Clock ;)
I don't believe .NET has an NTP client built in, but there are quite a few available.