如何实现在Web应用程序时区? [英] How to implement timezone in a web application?

查看:464
本文介绍了如何实现在Web应用程序时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要实现我的web应用程序的时区。我研究,看到大多数Web应用程序使用GMT下拉列表中,这里是链接到下拉的http://www.attackwork.com/BlogEntry/6/Time-Zone-Dropdown-Select-List/Default.aspx

然后我看到这篇文章暗示UTC是当它涉及到实施时区的路要走。 http://aspnet.4guysfromrolla.com/articles/081507-1.aspx 基本上它的说法不使用 DateTime.Now 而不是使用 DateTime.UtcNow

我的问题是,


  1. 是否有UTC的时区的下拉列表中,像第一个环节我发现有一个在格林尼治标准​​时间?

  2. 我应该真正使用UTC或GMT?


解决方案

.NET 3.5提供的的TimeZoneInfo 类,这应该让相对简单,为您填充时区下拉。格林尼治标准​​时间到来之前UTC与UTC 1月1日正式设立,1972年见此链接了解更多信息。对于今天的目的,两者是pretty多的代名词,尽管他们有着不同的历史渊源。无论使用何种外观和功能,更好地为您的目的。

I want to implement timezone in my web application. I researched and saw most web app use a GMT dropdown, here is the link to that dropdown http://www.attackwork.com/BlogEntry/6/Time-Zone-Dropdown-Select-List/Default.aspx

Then I saw this article suggesting UTC is the way to go when it comes to implement timezone. http://aspnet.4guysfromrolla.com/articles/081507-1.aspx Basically it's saying don't use DateTime.Now instead use DateTime.UtcNow

My questions are,

  1. Is there a dropdown of the timezones in UTC, like the first link I showed there is one on GMT?
  2. Should I really use UTC or GMT?

解决方案

.NET 3.5 provides the TimeZoneInfo class which should make it relatively simple for you to populate a dropdown with time zones. GMT came before UTC and UTC was officially instituted on January 1, 1972. See this link for more information. For today's purposes, the two are pretty much synonymous, though they have different historical origins. Use whichever looks and functions better for your purposes.

这篇关于如何实现在Web应用程序时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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