如何在asp.net c#中将东部时区转换为印度标准时间? [英] How to convert eastern time zone to indian standard time in asp.net c#?
本文介绍了如何在asp.net c#中将东部时区转换为印度标准时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在godaddy服务器上托管我的项目。
该服务器仅支持美国时间,因此我需要将该服务器时间转换为印度时间。
如何在日光变化时将美国时间转换为印度时间?
I host my project in godaddy server.
That server only support U.S. timing so i need to convert that server time to indian time.
How to convert U.S. time to Indian time with daylight changes?
推荐答案
将语言环境设置为假设您已正确编码您的网站,那么您希望在web.config和任何datetime \ _currency等格式中遵循该格式。
https://msdn.microsoft.com/en-gb/library/hy4kkhe0(v = vs.85 ).aspx [ ^ ]
Set the locale to the one you want in the web.config and any datetime\currency etc formatting should adhere to that assuming you have coded your site correctly.
https://msdn.microsoft.com/en-gb/library/hy4kkhe0(v=vs.85).aspx[^]
考虑使用 TimeZoneInfo.ConvertTime方法 [ ^ ]:
Consider to use TimeZoneInfo.ConvertTime Method[^]:
DateTime hwTime = new DateTime(2007, 02, 01, 08, 00, 00);
try
{
TimeZoneInfo hwZone = TimeZoneInfo.FindSystemTimeZoneById("Hawaiian Standard Time");
Console.WriteLine("{0} {1} is {2} local time.",
hwTime,
hwZone.IsDaylightSavingTime(hwTime) ? hwZone.DaylightName : hwZone.StandardName,
TimeZoneInfo.ConvertTime(hwTime, hwZone, TimeZoneInfo.Local));
}
catch (TimeZoneNotFoundException)
{
Console.WriteLine("The registry does not define the Hawaiian Standard Time zone.");
}
catch (InvalidTimeZoneException)
{
Console.WriteLine("Registry data on the Hawaiian STandard Time zone has been corrupted.");
}
这篇关于如何在asp.net c#中将东部时区转换为印度标准时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文