System.DateTimeEpochExtensions.ToEpochTime C# (CSharp) Method

ToEpochTime() public static method

Converts the given date value to epoch time.
public static ToEpochTime ( this dateTime ) : long
dateTime this
return long
        public static long ToEpochTime(this DateTime dateTime)
        {
            var date = dateTime.ToUniversalTime();
            var ts = date - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);

            return Convert.ToInt64(ts.TotalSeconds);
        }