UIDatePicker Question


#1

For some reason my reminder date that is showing up as logged is not the same that I am picking in the UIDatePicker. It is logging a date that is 6 hrs ahead of what the interface says I am picking. How is this possible and what am I missing? thanks in advance for any help!


#2

It’s just the default behavior (put the UTC instead of your local time)… But no worries, this won’t happen when your App is up and running :wink:


#3

Thanks Dave. That is good to know.


#4

I did this to make my log output in sync with the app:

NSDate *date = self.datePicker.date; NSDateFormatter *nsd = [[NSDateFormatter alloc]init]; nsd.timeZone = [NSTimeZone localTimeZone]; nsd.locale = [NSLocale currentLocale]; nsd.dateStyle = NSDateFormatterShortStyle; nsd.timeStyle = NSDateFormatterShortStyle; NSLog(@"Setting a reminder for %@", [nsd stringFromDate:date] );


#5

Great, this answered my question 2. The date picker is logging a time 4 hours ahead of me. I’m surprised they don’t mention this in the book.


#6

Is this a Xcode bug? I am pretty sure that it worked before I upgraded the Xcode. I would picked a time one minute from now, and it would show the notice one minute later.

After I upgraded Xcode recently (a few days back) the date picker started to return GMT date time, so when it does NSLog, it says it’s 4 hours ahead, and also the UILocalNotification is no longer working right away (I chose 1 minute from now, with this GMT date, it actually scheduled it 4 hours later).

I see you can change the date back by using the DateFormatter, but it still does not change the date object returned from UIDatePicker, right?

Any suggestions?


#7

[quote=“shenyu”]Is this a Xcode bug? I am pretty sure that it worked before I upgraded the Xcode. I would picked a time one minute from now, and it would show the notice one minute later.

After I upgraded Xcode recently (a few days back) the date picker started to return GMT date time, so when it does NSLog, it says it’s 4 hours ahead, and also the UILocalNotification is no longer working right away (I chose 1 minute from now, with this GMT date, it actually scheduled it 4 hours later).

I see you can change the date back by using the DateFormatter, but it still does not change the date object returned from UIDatePicker, right?

Any suggestions?[/quote]

This “issue” is only for the logging due to the default implementation of -description for NSDate. The app works fine; the code other people are posting help get the console output for NSDate in line with what they are seeing in the UI.