简体   繁体   中英

NSDate without timezone for a UIDatePicker

I have a UIDatePicker which I'm using to choose the opening time of a shop.

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.

For example, my NSDate is set as 2001-01-01T09:15:00Z. ie 9:15am on 1st Jan 2001.

I set my UIDatePicker date to this date, but when I open the app in Spain (which is GMT-1) I see 10:15am.

I'm not using a dateFormatter here - just regular NSDate. Is there a way of telling the UIDatePicker to ignore the timezone?

Or perhaps I shouldn't be storing the time as an NSDate because of the inherent timezone issues?

NSDatePicker has timeZone property - The time zone reflected in the date displayed by the date picker. See if that will help you...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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