To Unix Time Ms from DateTime - CSharp System

CSharp examples for System:DateTime Unix

Description

To Unix Time Ms from DateTime

Demo Code


using System.Text;
using System.Collections.Generic;
using System;/*from   ww w  .j  a  va2s  .  c o  m*/

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

Related Tutorials