CSharp examples for System:DateTime Unix
Returns a unix Epoch time given a Date
public class Main{ /// <summary> /// Returns a unix Epoch time given a Date /// </summary> public static long ToEpochTime(this DateTime dt, bool toMilliseconds = false) {/*from w ww . j a v a2 s.co m*/ var seconds = (long) (dt - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds; return toMilliseconds ? seconds * 1000 : seconds; } }