不同国家的日期和时间 [英] different countries date and time

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

问题描述

hai to all,

我的问题是我希望根据当地时间存储不同的国家/地区。实际上我的服务器在dullas。然后它显示和存储dullas时间。如何更改或存储全国范围的时间。



ex:在印度它显示并存储印度时间,在美国显示并存储美国时间

hai to all,
my question is i want store different countries times based on their local time. actually my server in dullas. then it shows and stores dullas time. how to change or store country wide timings.

ex: in india it shows and stores india time, in usa it shows and stores usa time

推荐答案

至少当我处理这个问题时,Web应用程序中使用的所有时间都是使用此站点的时间机器,无论此服务器的时间如何。

但你可能需要配置Global.asax.vb(或只是Global.asax)

使用以下行:



At least when I deal with this all the time used in Web Application is the time machine using this site, regardless of the time that this server.
But you may need to configure Global.asax.vb (or just Global.asax)
With the following line:

Public nfi2 As CultureInfo = CultureInfo.InvariantCulture





使用数据时,您可以使用本地文化机器的价值。

例如:





And when using the data, you can use the value of local culture machine.
example:

Date.ParseExact(TextBoxDate.Text.Trim(), "d/M/yyyy", nfi2)


始终存储DateTi me.UtcNow而不是DateTime.Now。因此无论位置如何,您都将获得通用时间。



阅读本文以了解有关UTC的详细信息。

http://msdn.microsoft.com/en-us/library/system。 datetime.touniversaltime(v = vs.100).aspx [ ^ ]



在检索/显示时,使用CurrentTimeZone和UtcOffset计算本地时间根据位置获取实际时间。



有关UTC偏移的更多详细信息,请阅读此内容。

http://msdn.microsoft.com/en-us/library/system.timezone.getutcoffset (v = vs.100).aspx [ ^ ]
Always store DateTime.UtcNow rather than DateTime.Now. So that you will get a Universal Time irrespective of the location.

Read this for more details about UTC.
http://msdn.microsoft.com/en-us/library/system.datetime.touniversaltime(v=vs.100).aspx[^]

While retrieving/displaying, calculate Local time using CurrentTimeZone and UtcOffset to get the actual time based on the location.

Read this for more details about UTC Offset.
http://msdn.microsoft.com/en-us/library/system.timezone.getutcoffset(v=vs.100).aspx[^]


这篇关于不同国家的日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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