Convert to Unix Time - CSharp System

CSharp examples for System:DateTime Unix

Description

Convert to Unix Time

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//  w  w w.  j  av  a  2s.  co  m

public class Main{
        public static long ConverttoUnixTime(System.DateTime time)
        {
            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
            return (int)(time - startTime).TotalSeconds;
        }
}

Related Tutorials