简体   繁体   English

没有时区的NSDate用于UIDatePicker

[英]NSDate without timezone for a UIDatePicker

I have a UIDatePicker which I'm using to choose the opening time of a shop. 我有一个UIDatePicker,可以用来选择一家商店的营业时间。

The problem is that the date picker is changing the displayed time depending on the timezone, but I just want to show the time exactly as it appears in the NSDate. 问题在于日期选择器正在根据时区更改显示的时间,但是我只想显示与NSDate中显示的时间完全相同的时间。

For example, my NSDate is set as 2001-01-01T09:15:00Z. 例如,我的NSDate设置为2001-01-01T09:15:00Z。 ie 9:15am on 1st Jan 2001. 即2001年1月1日上午9:15。

I set my UIDatePicker date to this date, but when I open the app in Spain (which is GMT-1) I see 10:15am. 我将UIDatePicker日期设置为该日期,但是当我在西班牙(格林尼治标准时间1)打开应用程序时,我看到的是上午10:15。

I'm not using a dateFormatter here - just regular NSDate. 我不是在这里使用dateFormatter-只是常规的NSDate。 Is there a way of telling the UIDatePicker to ignore the timezone? 有没有办法告诉UIDatePicker忽略时区?

Or perhaps I shouldn't be storing the time as an NSDate because of the inherent timezone issues? 还是由于固有的时区问题,我不应该将时间存储为NSDate吗?

NSDatePicker has timeZone property - The time zone reflected in the date displayed by the date picker. NSDatePicker具有timeZone属性-在日期选择器显示的日期中反映的时区。 See if that will help you... 看看是否对您有帮助...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM