Dmitriy Kalachniuk
Dmitriy Kalachniuk

Reputation: 372

Time picker shows wrong time iphone sdk

I have time picker in my app. I'm showing timePicker.date and the time is wrong. NSLog is

 NSLog (@"date : %@",[timePicker.date description]);

log is like date: 2012-02-07 17:00:01 +0000

i think that problem is in timezone

in ViewDidLoad i have this code

timePicker.locale = [NSLocale currentLocale];
timePicker.timeZone = [NSTimeZone localTimeZone];

but it isn't working...

Can somebody help me to solve my problem. Thanks

Upvotes: 1

Views: 1384

Answers (1)

Tim Dean
Tim Dean

Reputation: 8292

It is likely that the time picker is correctly applying time zone, but you're logging it using GMT rather than local time so that it just looks wrong. If you want to display the time returned from your time picker using local time, use NSDate's descriptionWithCalendarFormat:timeZone:locale: method, or use the NSDateFormatter class to get complete control over how your date is displayed.

Upvotes: 2

Related Questions