当我这样做时,我有相同的结果 1338161400
DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
DateTime date = DateTime.Parse(@"28/05/12 01:30");
TimeSpan diff = date.ToUniversalTime() - origin;
Console.WriteLine( (Math.Floor(diff.TotalSeconds)).ToString());
以及当我使用 date.AddHours(-4) 时:
DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
DateTime date = DateTime.Parse(@"28/05/12 01:30");
date.AddHours(-4);
TimeSpan diff = date.ToUniversalTime() - origin;
Console.WriteLine( (Math.Floor(diff.TotalSeconds)).ToString());
我尝试像http://www.mbari.org/staff/rich/utccalc.htm一样获得 1338168600
更新:
谢谢我改成
DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
DateTime date = DateTime.Parse(@"28/05/2012 01:30");
date = date.AddHours(-4);
date = date.ToUniversalTime();
TimeSpan diff = date - origin;
Console.WriteLine((Math.Floor(diff.TotalSeconds)).ToString());
但我得到了 1338147000 仍然不是 1338168600