C# – EpochTime

Snipplet code to convert current date time to epoch time
you may go to http://www.epochconverter.com/ to check the result.

public long GetEpochTime()
        {
            DateTime dtCurTime = DateTime.Now;
            DateTime dtEpochStartTime = Convert.ToDateTime("1/1/1970 00:00:00 AM");
            TimeSpan ts = dtCurTime.Subtract(dtEpochStartTime);

            long epochtime;
            epochtime = ((((((ts.Days * 24) + ts.Hours) * 60) + ts.Minutes) * 60) + ts.Seconds);
            return epochtime;
        }
Related Posts with Thumbnails

Incoming search terms:

  • diary in c#
  • c# converttodatetime epoch
  • Convert ToDateTime() long
  • EpochTime C#
  • getepochtime c#

Tags: , ,

No comments yet.

Leave a Reply

Get Adobe Flash playerPlugin by wpburn.com wordpress themes