It's every developers horror story. TIMEZONES!!! It's something that should work really well but never does.

In this post I'm going to spend some time exploring Nodatime and it's timezone class and how it works. It does a really good job of making this easy for those of us using C#.

Timezone Data

Noda time keeps an up to date database of timezone information for you. https://nodatime.org/TimeZones or you can get it from noda time in code,

var timeZones = TimeZoneInfo.GetSystemTimeZones();

foreach (var oTimeZone in timeZones)
{
    Console.WriteLine("TimeZone: " + oTimeZone.DisplayName + " Id: " + oTimeZone.Id);
}
NodaTime - Timezone information

This code will give you all the timezones in Nodatime.

For converting and doing the basics on Noda Time check out my post Using Noda Time in .NET

The full Noda Time documentation for timezones is here

Using Timezones

When storing a users information I story the timezone against the user. Then I store times as local time. So what ever timezone the user is in I will try and store and display the time in that format.

This gives me an advantage that the user is always looking at the right time. I then convert the users time back to UTC. Once I have a time in UTC, Noda Time makes it easy to convert from UTC to any time and vice versa.

Trying to convert from one time zone to another should always be a 2 step process.