Datetime.Today in GMT in c#

C#DatetimeTimezone

C# Problem Overview


I want to convert DateTime.Today to GMT time.

i.e. If I am in L.A. and it is 11pm of 22/02/2012 I want DateTime.Today to be 23/02/2012 because it will be that day in GMT time.

C# Solutions


Solution 1 - C#

There is no DateTime.UtcToday, but you can try DateTime.UtcNow.Date

Solution 2 - C#

DateTime.UtcNow will give you the current universal time.

Solution 3 - C#

DateTime LocalToGMT = DateTime.Now.ToUniversalTime().AddHours(TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time").BaseUtcOffset.Hours);

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTonyView Question on Stackoverflow
Solution 1 - C#Carsten SchütteView Answer on Stackoverflow
Solution 2 - C#rirajatView Answer on Stackoverflow
Solution 3 - C#Paul SuitelaView Answer on Stackoverflow