Calculates the Unix epoch for the date - CSharp System

CSharp examples for System:DateTime Unix

Description

Calculates the Unix epoch for the date

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from  w ww .j  ava  2s  .  c om*/

public class Main{
        /// <summary>
        /// Calculates the Unix epoch for the date
        /// </summary>
        /// <returns>The Unix epoch</returns>
        public static long ToUnixEpoch(this DateTime date)
        {
            return (date.Ticks - 621355968000000000) / 10000000;
        }
}

Related Tutorials