// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; namespace E { public class Program { private static long k = (new DateTime(1970, 1, 1, 0, 0, 0) + TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now)).Ticks; public static int N2U(DateTime dt) { return (int)((dt.Ticks - k) / 10000000); } public static DateTime U2N(int t) { return new DateTime(t * 10000000L + k); } public static void Main(string[] args) { DateTime dt = DateTime.Now; Console.WriteLine(dt); int t = N2U(dt); Console.WriteLine(t); DateTime dt2 = U2N(t); Console.WriteLine(dt2); } } }