Skip to content

Instantly share code, notes, and snippets.

@liddellj
Created May 19, 2011 11:39
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liddellj/980566 to your computer and use it in GitHub Desktop.
Save liddellj/980566 to your computer and use it in GitHub Desktop.
C# DateTime to Unix Timestamp Extension Method
public static class DateTimeExtensions
{
public static long ToUnixTimestamp(this DateTime d)
{
var duration = d - new DateTime(1970, 1, 1, 0, 0, 0);
return (long)duration.TotalSeconds;
}
}
@liddellj
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment