Get Epoch Date Time - CSharp System

CSharp examples for System:DateTime

Description

Get Epoch Date Time

Demo Code


using System;/*from  w  w  w.j ava  2 s  . c om*/

public class Main{
        public static long GetEpochDateTime(this DateTime dateTime) {
            return (long)(dateTime - new DateTime(1970, 1, 1)).TotalSeconds;
        }
}

Related Tutorials