To Unix Timespan - CSharp System

CSharp examples for System:DateTime Unix

Description

To Unix Timespan

Demo Code


using System;//www. j av  a 2s .c  o m

public class Main{
        public static long ToUnixTimespan(DateTime date)
        {
            TimeSpan tspan = date.ToUniversalTime().Subtract(new DateTime(1970, 1, 1, 0, 0, 0));
            return (long)Math.Truncate(tspan.TotalSeconds);
        }
}

Related Tutorials