改变美国的冬季和夏季时间 [英] changing US winter and summer time

查看:222
本文介绍了改变美国的冬季和夏季时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站上,我有一个时钟显示美国时间。

有一个简单的方法可以从夏天到冬天更换

或者我必须更改我的每个冬季和夏季的代码

我使用ASP.NET与C#

On my site I have a clock that displays US time.
Is there a simple way to change from summer time to winter time
or I have to change my code every winter and summer
I am using ASP.NET with C#

推荐答案

这取决于用于托管HTTP服务器的操作系统,但是大部分操作系统都配置为根据位置和日期自动切换夏季保存时间班次。你不必担心它。 System.DateTime.Now 只会给你正确的时间。



另一种解决方案是仅使用UTC时间服务器端( System.DateTime.UtcNow 。根据本地系统的位置和文化,客户端代码可以将UTC转换为当地时间。



请参阅:

http://msdn.microsoft.com/en-us/library/System.DateTime%28v=vs.110%29.aspx [ ^ ],

http://msdn.microsoft .com / zh-cn / library / system.datetime.now(v = vs.110).aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system.datetime.utcnow%28v=vs.110%29 .aspx [ ^ ]。



-SA
It depends on the OS used to host your HTTP server, but most of OS are configured to automatically switch summer saving time shift on and off, depending on location and date. You don't have to worry about it. System.DateTime.Now will simply give you correct time.

Another solution is to use UTC time only on the server side (System.DateTime.UtcNow. The client-side code can translate UTC to their local times, according to the location and culture of the local systems.

Please see:
http://msdn.microsoft.com/en-us/library/System.DateTime%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.datetime.now(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/system.datetime.utcnow%28v=vs.110%29.aspx[^].

—SA


这篇关于改变美国的冬季和夏季时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆