Created
January 18, 2015 11:31
-
-
Save alexander-williamson/e977f0ed4bd11bb6f3c7 to your computer and use it in GitHub Desktop.
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 static class UnixTimestamp | |
{ | |
private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); | |
public static double Convert(this DateTime dateTime) | |
{ | |
return dateTime.Subtract(Epoch).TotalMilliseconds; | |
} | |
public static DateTime Convert(this double offset) | |
{ | |
return Epoch.AddMilliseconds(offset); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment