首页 新闻 赞助 找找看

[急]关于时区的问题?

0
悬赏园豆:5 [已关闭问题] 关闭于 2008-08-12 12:27
<P>快刀剁乱麻,知道帮下啊,小第急用.</P> <P>大体情况是这样的,客户要求采集到访问他门网站的用户的时区. 我不知道该怎么去获取时区,有知道帮忙解答下,谢谢了.</P>
Bēniaǒ的主页 Bēniaǒ | 小虾三级 | 园豆:692
提问于:2008-08-07 23:00
< >
分享
所有回答(3)
0
TimeZone.CurrentTimeZone.StandardName 给你个例子看看 using System; using System.Globalization; class TimeZoneDemo { static void Main( ) { const string dataFmt = "{0,-30}{1}"; const string timeFmt = "{0,-30}{1:yyyy-MM-dd HH:mm}"; Console.WriteLine( "This example of selected TimeZone class " + "elements generates the following \n" + "output, which varies depending on the " + "time zone in which it is run.\n" ); // Get the local time zone and the current local time and year. TimeZone localZone = TimeZone.CurrentTimeZone; DateTime currentDate = DateTime.Now; int currentYear = currentDate.Year; // Display the names for standard time and daylight saving // time for the local time zone. Console.WriteLine( dataFmt, "Standard time name:", localZone.StandardName ); Console.WriteLine( dataFmt, "Daylight saving time name:", localZone.DaylightName ); // Display the current date and time and show if they occur // in daylight saving time. Console.WriteLine( "\n" + timeFmt, "Current date and time:", currentDate ); Console.WriteLine( dataFmt, "Daylight saving time?", localZone.IsDaylightSavingTime( currentDate ) ); // Get the current Coordinated Universal Time (UTC) and UTC // offset. DateTime currentUTC = localZone.ToUniversalTime( currentDate ); TimeSpan currentOffset = localZone.GetUtcOffset( currentDate ); Console.WriteLine( timeFmt, "Coordinated Universal Time:", currentUTC ); Console.WriteLine( dataFmt, "UTC offset:", currentOffset ); // Get the DaylightTime object for the current year. DaylightTime daylight = localZone.GetDaylightChanges( currentYear ); // Display the daylight saving time range for the current year. Console.WriteLine( "\nDaylight saving time for year {0}:", currentYear ); Console.WriteLine( "{0:yyyy-MM-dd HH:mm} to " + "{1:yyyy-MM-dd HH:mm}, delta: {2}", daylight.Start, daylight.End, daylight.Delta ); } }
Jerry Young | 园豆:435 (菜鸟二级) | 2008-08-08 00:28
0
在网上找一个国家IP范围数据库,根据用户IP,判断他所在的国家,然后使用此国家的基本时区。
deerchao | 园豆:8367 (大侠五级) | 2008-08-08 02:22
0
Jared.Nie | 园豆:1940 (小虾三级) | 2008-08-08 11:39
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册