Create Date Time Offset - CSharp System

CSharp examples for System:DateTimeOffset

Description

Create Date Time Offset

Demo Code


using System.Globalization;
using System;// w w  w.jav a2s.c  o m

public class Main{
        public static DateTimeOffset CreateDateTimeOffset(DateTime dateTime, TimeZoneInfo imageSetTimeZone)
        {
            if (dateTime.Kind == DateTimeKind.Unspecified)
            {
                TimeSpan utcOffset = imageSetTimeZone.GetUtcOffset(dateTime);
                return new DateTimeOffset(dateTime, utcOffset);
            }
            return new DateTimeOffset(dateTime);
        }
}

Related Tutorials