直接上代码:
var date = new DateTime(2013, 6, 2, 8, 0, 0); // 要转换的日期 var timestamp = (long)(date.ToUniversalTime().Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds; Console.WriteLine("Timestamp: " + timestamp); return View();
运行效果: