CSharp examples for System:DateTime Unix
Converts a DateTime to Unix time
using System;/* ww w.j a v a2 s . c om*/ public class Main{ /// <summary> /// Converts a DateTime to Unix time /// </summary> /// <param name="dateTime"></param> /// <returns></returns> public static long ToUnixTimeStamp(this DateTime dateTime) { DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0); TimeSpan timeSpanSinceOrigin = dateTime.Subtract(origin); return Convert.ToInt64(timeSpanSinceOrigin.TotalSeconds); } }