Get Offset DateTime String - CSharp System

CSharp examples for System:DateTimeOffset

Description

Get Offset DateTime String

Demo Code


using System;/*from  w ww  . j a  va 2s  . co  m*/
using Bridge.Test.NUnit;

public class Main{
        public static string GetOffsetString(int adjustment = 0)
        {
            var minutes = GetOffsetMinutes() + adjustment;

            var b = minutes < 0 ? "+" : "-";
            minutes = Math.Abs(minutes);

            var offset = minutes != 0
                ? (b + (minutes / 60).ToString("00") + ":" + (minutes % 60).ToString("00"))
                : "Z";

            return offset;
        }
}

Related Tutorials