Created
March 6, 2015 18:31
-
-
Save jrolstad/e9fc5da79ea401522016 to your computer and use it in GitHub Desktop.
How to convert to Local Time
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
[Test] | |
[TestCase("America/Los_Angeles")] | |
[TestCase("Australia/Sydney")] | |
public void ShowLocalTimes(string timezone) | |
{ | |
var someDate = DateTime.Now.ToUniversalTime(); | |
var instant = Instant.FromDateTimeUtc(someDate); | |
var timeZone = DateTimeZoneProviders.Tzdb.GetZoneOrNull(timezone); | |
var localTime = instant.InZone(timeZone); | |
Console.WriteLine(localTime.ToDateTimeUnspecified()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment