Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 314
user62958 Avatar asked Feb 05 '09 16:02

user62958


People also ask

What is our GMT time zone?

The Greenwich Mean Time corresponds to the time zone UTC 0, i.e. the Coordinated World Time with an offset of 0 hours. It essentially corresponds to Western European time, which is valid in Portugal, for example, but is officially referred to as GMT in the United Kingdom and several African countries.

Is the UK currently using GMT?

Please note: GMT is currently not observed in the UK.

Why is GMT no longer used?

The term GMT should thus not be used for purposes that require precision. Because of Earth's uneven angular velocity in its elliptical orbit and its axial tilt, noon (12:00:00) GMT is rarely the exact moment the Sun crosses the Greenwich Meridian and reaches its highest point in the sky there.


1 Answers

Instead of calling

DateTime.Now.ToUniversalTime() 

you can call

DateTime.UtcNow 

Same thing but shorter :) Documentation here.

like image 147
Alex Avatar answered Oct 24 '22 17:10

Alex