To Unix Time from DateTime - CSharp System

CSharp examples for System:DateTime Unix

Description

To Unix Time from DateTime

Demo Code


using System.Text;
using System.Collections.Generic;
using System;/*www.  j  av  a2  s .  c  o  m*/

public class Main{
        public static long ToUnixTime(this DateTime date)
      {
         var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
         return Convert.ToInt64((date - epoch).TotalSeconds);
      }
}

Related Tutorials