Getting current GMT time

user62958 picture user62958 · Feb 5, 2009 · Viewed 85.5k times · Source

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.

Answer

Alex picture Alex · Mar 12, 2012

Instead of calling

DateTime.Now.ToUniversalTime()

you can call

DateTime.UtcNow

Same thing but shorter :) Documentation here.