CSharp examples for System:DateTime Unix
Unix epoch time from a datetime
using System;/*from w w w. j a v a 2 s .co m*/ public class Main{ /// <summary> /// Unix epoch time from a datetime /// </summary> /// <param name="date"></param> /// <returns></returns> public static long DateTimeToEpochMilliseconds(this DateTimeOffset date) { var t = (date - new DateTimeOffset(1970, 1, 1,0,0,0,TimeSpan.Zero)); return (long)t.TotalMilliseconds; } }