C# Utc时间与本地时间转换, Utc DateTime 与 LocalTime 转换
using System;
namespace ConsoleApp15
{
class Program
{
static void Main(string[] args)
{
// 获取当前UTC+0时间
DateTime utcNow = DateTime.UtcNow;
// 输出本地时区时间
Console.WriteLine("Utc Time: {0}", utcNow.ToString());
Console.WriteLine("Local Time: {0}", utcNow.ToLocalTime());
// UTC时区时间转换, 指定为UTC时间
DateTime utc= DateTime.SpecifyKind(Convert.ToDateTime("2018/08/09 00:23:56"), DateTimeKind.Utc);
// 转换为当前系统时区时间
DateTime local = utc.ToLocalTime();
// 输出转换到本地时间
Console.WriteLine("Local Time: {0}", local.ToLocalTime());
Console.Read();
}
}
}