i can’t understand why i can’t change the hour of a NSDate correctly, using NSDateComponents, i’ll do it in this way:
NSDateComponent components = [calendar components: (NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:today];
[components setMinute:myMinute];
[components setHour:7];
NSDate *myNewDate = [calendar dateFromComponents:components];
NSLog(@"%@",myNewDate);
but the NSLog is this:
2012-12-08 06:00:00 +0000
there is one hour of difference, i have set 7 but is 6 anyone can help me?
its the timezone – the NSDate is printed with GMT time as it has no notion of timezones
use
to make the components GMT and reflect your time set
working example