我有同樣的結果1338161400當我做爲什麼DateTime.AddHours似乎不起作用?
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());
我試圖讓1338168600像http://www.mbari.org/staff/rich/utccalc.htm
更新:
謝謝我改爲
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
+1爲不可變的呼叫。 –
正確的答案我必須等待6分鐘,然後再根據計算器規則檢查它爲好的答案。但是我已經更新了我的帖子,你能否看一下謝謝? – user310291
終於不知道我只需要添加+2代替:) – user310291