Skip to content

Instantly share code, notes, and snippets.

@avenet
Last active August 29, 2015 14:03
Show Gist options
  • Save avenet/51ccca92fb98001b4977 to your computer and use it in GitHub Desktop.
Save avenet/51ccca92fb98001b4977 to your computer and use it in GitHub Desktop.
Retrieves the local offset hours based on the current date
using System;
namespace Avenet.Utils
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(GetLocalOffsetHours());
}
private static int GetLocalOffsetHours()
{
TimeZone localZone = TimeZone.CurrentTimeZone;
var offset = localZone.GetUtcOffset(DateTime.Now);
return offset.Hours;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment