Skip to content

Instantly share code, notes, and snippets.

@alexsandro-xpt
Created October 13, 2012 17:40
Show Gist options
  • Save alexsandro-xpt/3885498 to your computer and use it in GitHub Desktop.
Save alexsandro-xpt/3885498 to your computer and use it in GitHub Desktop.
Convert .net DateTime to JavaScript Timestamp and vice versa
var timestamp = (long)DateTime.UtcNow
.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc))
.TotalMilliseconds;
//http://stackoverflow.com/questions/1877788/javascript-date-to-c-sharp-via-ajax
var date = new DateTime(1970, 1, 1).AddTicks(timestamp * 10000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment