System.DateTimeEpochExtensions.ToEpochTime C# (CSharp) Méthode

ToEpochTime() public static méthode

Converts the given date value to epoch time.
public static ToEpochTime ( this dateTime ) : long
dateTime this
Résultat 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);
        }