Computing milliseconds since 1970 in C# yields different date than JavaScript
问题 I need to compute the JavaScript getTime method in C#. For simplicity, I chose a fixed date in UTC and compared the C#: C# DateTime e = new DateTime(2011, 12, 31, 0, 0, 0, DateTimeKind.Utc); DateTime s = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); TimeSpan t = (e - s); var x = t.TotalMilliseconds.ToString(); => 1325289600000 and the JavaScript results: JavaScript var d = new Date(2011, 12, 31, 0, 0, 0) var utcDate = new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d