Jack Nutkins
Jack Nutkins

Reputation: 1555

NSDate early by 1 hour?

I am using the following code to set a date object:

NSDate *date = [NSDate date];
        NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar];
        NSDateComponents *components = [gregorian components: NSUIntegerMax fromDate: date];
        [components setHour: 18];
        [components setMinute: 00];
        [components setSecond: 00];

        reminderDate = [gregorian dateFromComponents: components];

However, when I NSLog reminderDate I get the following output:

Time: 2012-08-29 17:00:00 +0000

Which is early by one hour, can anyone explain what it is I need to do in order to store the correct date in reminderDate?

Thanks,

Tysin

Upvotes: 0

Views: 531

Answers (1)

alfonsomiranda
alfonsomiranda

Reputation: 102

What is your time zone? If you notice, the date that you print has +0 time zone, so if your time zone is +1 is all correct.

Upvotes: 2

Related Questions