2

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. 最初に示したリンクが GMT にあるように、UTC のタイムゾーンのドロップダウンはありますか?
  2. 本当に UTC または GMT を使用する必要がありますか?
4

6 に答える 6

3

.NET 3.5 はTimeZoneInfoクラスを提供します。これにより、ドロップダウンにタイム ゾーンを設定することが比較的簡単になります。GMT は UTC の前に登場し、UTC は 1972 年 1 月 1 日に正式に制定されました。詳細については、このリンクを参照してください。今日の目的では、この 2 つはほぼ同義ですが、歴史的な起源は異なります。目的に合わせて、見た目と機能が優れている方を使用してください。

于 2009-01-27T22:51:27.060 に答える
2

I'm not sure if this is what you intended to ask, but in your database you should always store timestamps in UTC/GMT (as noted by others they mean essentially the same thing). For each user of your web app, store the time zone preference.

Then whenever you display the timestamp for something to a user, convert the UTC time in the database to the user's timezone.

于 2009-01-27T22:58:15.440 に答える
1

GMT (グリニッジ標準時) は UTC (協定世界時) と同じです。これはどちらかまたは両方の選択ではありません - 使用してください:)

于 2009-01-27T22:43:29.837 に答える
0

The distinction between UTC and GMT is probably too fine to bother with in your code. However, it's probably a good idea to always save and process times internally with zero timezone offset, and deal with it as a presentation concern.

It's also possible to use JavaScript to determine the user's probable timezone: examine the timezone offsets for some pair of Date objects reasonably close to the solstices (even January 1 and July 1 makes a suitable approximation) to obtain a coarse timezone identification. Feel free to use this information to determine a default timezone, but do allow it to be changed by the user: JavaScript doesn't provide sufficient detail to select the exact timezone with national and regional historical shifts, and it may not be enabled by the user anyway.

于 2009-01-27T23:00:18.057 に答える
0

ローカリゼーションの設定、機能、機能を可能な限り使用してください。

于 2009-01-27T22:53:36.337 に答える
0

SQL Server 2008 に対して実行していない場合、またはタイムゾーン管理をデータベースに抽象化したくない場合は、すべての時間を UTC/GMT として保存し、ユーザーのプロファイル設定に基づいてタイムゾーンの違いを適用する必要があります。世界はイベントのタイムスタンプを現地時間で見ることができます。

于 2009-01-27T22:53:48.770 に答える