C# UTC和世界时
在C#中,UTC和世界时的区别是什么?C# UTC和世界时,c#,.net,datetime,C#,.net,Datetime,在C#中,UTC和世界时的区别是什么? 可用的功能有哪些?没有区别。DateTime.UtcNow以UTC为单位提供当前时间。Timezone类具有将UTC日期/时间转换为任何时区中的日期/时间的函数。没有区别。DateTime.UtcNow以UTC为单位提供当前时间。Timezone类具有在任何时区转换UTC日期/时间和UTC日期/时间的函数。我认为它们是相同的-根据,UTC是协调的*世界*时间 .NET通过结构上的许多函数支持UTC。例如,有像DateTime.ToUniversalTime
可用的功能有哪些?没有区别。DateTime.UtcNow以UTC为单位提供当前时间。Timezone类具有将UTC日期/时间转换为任何时区中的日期/时间的函数。没有区别。DateTime.UtcNow以UTC为单位提供当前时间。Timezone类具有在任何时区转换UTC日期/时间和UTC日期/时间的函数。我认为它们是相同的-根据,UTC是协调的*世界*时间
.NET通过结构上的许多函数支持UTC。例如,有像
DateTime.ToUniversalTime
(当然还有DateTime.ToLocalTime
转换回)或DateTime.UtcNow
这样的函数可用。我认为它们都是一样的-根据,UTC是协调的*世界*时间
.NET通过结构上的许多函数支持UTC。例如,有像DateTime.ToUniversalTime
(当然还有DateTime.ToLocalTime
转换回)或DateTime.UtcNow
这样的函数可用。UTC=世界时
您可以通过以下方式将当前本地时间转换为UTC:
DateTime dt= DateTime.UtcNow;
或将指定的日期/时间转换为
TimeZoneInfo myTZInfo = TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time");
// DateTime.SpecifyKind(Convert.ToDateTime("04:35 AM"), DateTimeKind.Unspecified), myTZInfo) tells whether you are conetring a local time or UTC, you can always leave it as unspecified
TimeZoneInfo.ConvertTimeToUtc(DateTime.SpecifyKind(Convert.ToDateTime("2015-01-06 14:00:00.000"), DateTimeKind.Unspecified), myTZInfo).ToString("hh:mm tt")
您可以通过==>
ReadOnlyCollection<TimeZoneInfo> tzc= TimeZoneInfo.GetSystemTimeZones();
ReadOnlyCollection tzc=TimeZoneInfo.GetSystemTimeZones();
UTC=世界时
您可以通过以下方式将当前本地时间转换为UTC:
DateTime dt= DateTime.UtcNow;
或将指定的日期/时间转换为
TimeZoneInfo myTZInfo = TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time");
// DateTime.SpecifyKind(Convert.ToDateTime("04:35 AM"), DateTimeKind.Unspecified), myTZInfo) tells whether you are conetring a local time or UTC, you can always leave it as unspecified
TimeZoneInfo.ConvertTimeToUtc(DateTime.SpecifyKind(Convert.ToDateTime("2015-01-06 14:00:00.000"), DateTimeKind.Unspecified), myTZInfo).ToString("hh:mm tt")
您可以通过==>
ReadOnlyCollection<TimeZoneInfo> tzc= TimeZoneInfo.GetSystemTimeZones();
ReadOnlyCollection tzc=TimeZoneInfo.GetSystemTimeZones();