Created
July 9, 2020 12:00
-
-
Save alexandrebl/2e61ec0f3fb735e17b04af36f3c43de0 to your computer and use it in GitHub Desktop.
Get TimeZone Brazil CSharp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class TimeZoneBrazil | |
| { | |
| public static DateTime GetCurrentLocalDate() | |
| { | |
| long ticks; | |
| if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) | |
| { | |
| ticks = TimeZoneInfo | |
| .FindSystemTimeZoneById("America/Sao_Paulo") | |
| .GetUtcOffset(DateTime.UtcNow).Ticks; | |
| } | |
| else | |
| { | |
| ticks = TimeZoneInfo | |
| .FindSystemTimeZoneById("E. South America Standard Time") | |
| .GetUtcOffset(DateTime.UtcNow).Ticks; | |
| } | |
| var currentLocalDate = new DateTime(ticks); | |
| return currentLocalDate; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment