Date Time To Unix Timestamp Seconds - CSharp System

CSharp examples for System:DateTime Unix

Description

Date Time To Unix Timestamp Seconds

Demo Code


using System;/*from   www  . j a v  a  2 s.c om*/

public class Main{
        public static int DateTimeToUnixTimestampSeconds(this DateTime dateTime)
        {
            var time = (int)(dateTime - new DateTime(1970, 1, 1).ToLocalTime()).TotalSeconds;
            return time;
        }
}

Related Tutorials