如何:获得日期,时间和单DateTimePicker控件时区控件、时区、日期、时间

2023-09-07 00:34:32 作者:失去并非不是一种收获

我正在开发中,我试图将日期的应用程序,从单个的DateTimePicker 控制时间和时区。任何人可以帮助解决这个?

I am developing an application in which I am trying to fetch Date, Time and Time Zone from single DateTimePicker control. Can anybody help to resolve this?

修改1 我使用的.NET Framework 2.0。现在,我可以将日期和时间单的DateTimePicker 通过设置 CustomFormat 财产

Edit 1 I am using .NET Framework 2.0. Now I am able to fetch Date and Time with Single DateTimePicker by setting its CustomFormat property as

dtpicker2.CustomFormat = "MM/dd/yyyy,hh:mm:ss"

现在我的问题是要获取的时区。

Now my problem is to fetch TimeZone.

编辑2 现在,这里是多了一个问题,如果我设置的DateTimePicker 的格式属性时,它显示我像下午二时三十分零零秒。我这个存储在一个文件,并将其重新分配给的DateTimePicker 控制。 任何人可以帮助我,如何实现这一目标?

Edit 2 Now here is one more issue, if I set DateTimePicker's format property to Time, it shows me something like 2:30:00 PM. I am storing this in a file and reassigning it to the DateTimePicker control. Can anybody help me out, how to achieve this?

推荐答案

您将无法使用它自己的一个DateTimePicker做到这一点。

You won't be able to do it using a DateTimePicker on it's own.

相反,你将必须有某种复合控制其上有一个DateTimePicker,以及其他控制将作为偏移。

Rather, you are going to have to have sort of composite control which has a DateTimePicker on it, as well as another control which will serve as the offset.

这个控制可能是一个数字上/下控制你会使用的时,分,秒,等等,等等偏移量(或只是一个文本框为此事)。

This control could be a numeric up/down control which you would use for the hour, minute, second, etc, etc offset (or just a textbox for that matter).

另一种选择是,如果你有一个位置(以经纬度的形式的您可以通过HTTP 通过谷歌获得,如果你有一个地址),使用的时区的API在GeoNames的功能这将允许您通过经度和纬度值,它将返回时区的那个位置。也就是说,随着 TZ数据库和的区信息工程将允许您确定偏移在特定的日期/时间(这是不相同的所有地区,所有的日期)。

Another option is if you have a location (in the form of latitude and longitude, which you can obtain via Google through HTTP if you have an address), to use the Timezone API function at GeoNames which will allow you to pass a latitude and longitude value and it will return the timezone for that location. That, along with the TZ database and the ZoneInfo project will allow you to determine the offset at that particular date/time (which isn't the same for all locations and all dates).