Skip to content

Instantly share code, notes, and snippets.

@gon250
Created March 19, 2015 12:27
Show Gist options
  • Save gon250/52af833c88fd4fcad83e to your computer and use it in GitHub Desktop.
Save gon250/52af833c88fd4fcad83e to your computer and use it in GitHub Desktop.
public class JsDateHelper : IJsDateHelper
{
public DateTime FromUnixTime(double unixTime)
{
var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
return epoch.AddMilliseconds(unixTime);
}
public long ToUnixTime(DateTime date)
{
var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
return Convert.ToInt64((date - epoch).TotalMilliseconds);
}
}
var birthday = new Date(1994, 12, 10);
var time = birthday.getTime(); // 789696000000
var date2 = new Date(time); // Same as birthday
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment