To Unix Timestamp - CSharp System

CSharp examples for System:DateTime Unix

Description

To Unix Timestamp

Demo Code


using System.Web;
using System.Linq;
using System.Collections.Generic;
using System;// ww w. j  a  va  2  s  .c o  m

public class Main{
        public static long ToUnixTimestamp(this DateTime target)
        {
            var date = new DateTime(1970, 1, 1, 0, 0, 0, target.Kind);
            var unixTimestamp = System.Convert.ToInt64((target - date).TotalSeconds);

            return unixTimestamp;
        }
}

Related Tutorials