Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 用户转换的日期时间?_C#_.net_Datetime - Fatal编程技术网

C# 用户转换的日期时间?

C# 用户转换的日期时间?,c#,.net,datetime,C#,.net,Datetime,我从一个字符串的使用中得到了一个时间。该时间假定为东部时间。我需要将其作为UTC时间存储在数据库中。我该怎么做 DateTime.SpecifyKind不接受东部。在另一篇文章中,我读了一些关于使用DateTimeOffset的内容 DateTime dateNow=DateTime.Now; WriteLine(“日期和时间为{0}UTC。”, TimeZoneInfo.ConvertTimeToUtc(dateNow)); 来自: 相关问题:TimeZoneInfo是System.Core

我从一个字符串的使用中得到了一个时间。该时间假定为东部时间。我需要将其作为UTC时间存储在数据库中。我该怎么做

DateTime.SpecifyKind不接受东部。在另一篇文章中,我读了一些关于使用DateTimeOffset的内容

DateTime dateNow=DateTime.Now; WriteLine(“日期和时间为{0}UTC。”, TimeZoneInfo.ConvertTimeToUtc(dateNow));

来自:


相关问题:TimeZoneInfo是System.Core.dll中的一个对象。 DateTime dateNow = DateTime.Now; Console.WriteLine("The date and time are {0} UTC.", TimeZoneInfo.ConvertTimeToUtc(dateNow));
DateTime easternTime = new DateTime(2007, 01, 02, 12, 16, 00);
string easternZoneId = "Eastern Standard Time";
try
{
   TimeZoneInfo easternZone = TimeZoneInfo.FindSystemTimeZoneById(easternZoneId);
   Console.WriteLine("The date and time are {0} UTC.", 
                     TimeZoneInfo.ConvertTimeToUtc(easternTime, easternZone));
}
catch (TimeZoneNotFoundException)
{
   Console.WriteLine("Unable to find the {0} zone in the registry.", 
                     easternZoneId);
}                           
catch (InvalidTimeZoneException)
{
   Console.WriteLine("Registry data on the {0} zone has been corrupted.", 
                     easternZoneId);
}