本文介绍了转换EST / EDT为GMT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何转换EST / EDT为GMT日期时间,但我不知道在哪里的代码会跑(未知的本地时区),也占到节省时间...
How do I convert a DateTime from EST/EDT to GMT but I don't know where the code will be ran (unknown local time zone) and also account for time savings...
推荐答案
您想,它允许您通过源时区信息作为参数。例如:
You want TimeZoneInfo.ConvertTimeToUtc(), which allows you to pass the source time zone info as a parameter. For example:
TimeZoneInfo est = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
DateTime someDateTimeInUtc = TimeZoneInfo.ConvertTimeToUtc(someDateTime, est);
我的认为的这会自动处理夏令时,但你'会想测试是肯定的。
I think this will automatically handle daylight-saving time, but you'll want to test it to be sure.
这篇关于转换EST / EDT为GMT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!