Created
May 7, 2014 17:39
-
-
Save ubergoober/5ac490dbb2e5188d8b98 to your computer and use it in GitHub Desktop.
Convert CurrentDateTime to Epoch in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public long GetEpochTime() { | |
DateTime dtCurTime = DateTime.Now; | |
DateTime dtEpochStartTime = Convert.ToDateTime("1/1/1970 8:00:00 AM"); | |
TimeSpan ts = dtCurTime.Subtract(dtEpochStartTime); | |
long epochtime; | |
epochtime = ((((((ts.Days * 24) + ts.Hours) * 60) + ts.Minutes) * 60) + ts.Seconds); | |
return epochtime; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment