'Datetime.Today in GMT in c#
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.
Solution 1:[1]
There is no DateTime.UtcToday, but you can try DateTime.UtcNow.Date
Solution 2:[2]
DateTime.UtcNow will give you the current universal time.
Solution 3:[3]
DateTime LocalToGMT = DateTime.Now.ToUniversalTime().AddHours(TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time").BaseUtcOffset.Hours);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | CodesInChaos |
| Solution 2 | Ivar |
| Solution 3 | Paul Suitela |
