UTC とローカル時刻を表示する
using System; class Program { static void Main() { var utc = DateTime.UtcNow; var now = DateTime.Now; Console.WriteLine("utc now : {0}", utc); Console.WriteLine("utc now -> local : {0}", utc.ToLocalTime()); Console.WriteLine(" now : {0}", now); Console.WriteLine(" now -> universal : {0}", now.ToUniversalTime()); } }
実行結果です。
utc now : 2015/12/17 14:50:05 utc now -> local : 2015/12/17 23:50:05 now : 2015/12/17 23:50:05 now -> universal : 2015/12/17 14:50:05