Parse.com + NSDate : Convert Parse Date Retrieved to local timezone

I’m having a very hard problem downloading objects from parse for “TODAY”.

The objects I’m downloading are events. Each has a startTime property (NSDate) – which stores the date and the time of the event. From reading Parse documentation and other questions on stackoverflow.com, the dates in Parse are stored as “UTC” time zone.

When I do not get any results if I try to something like:

[query whereKey:@"startTime" greaterThan:[NSDate date]]; 

Right now I do not care about the time start time, just care about the date in the following format: “MM/dd”

I have tried to retrieve all the objects and convert the start times to local times but have not had any success. When I do the conversion, the startTimes are actually a day off (a day behind). So if the event is the 08/29 – it prints 08/28.

I tried to convert it to local time and then compare if the result is equal to today’s date but still no luck.

                 NSDate *today = [NSDate date];
//
//
                NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
//
                [dateFormat setDateFormat:@"MM/dd/"];
                [dateFormat Time:@"MM/dd/":[NSTimeZone systemTimeZone]];

//
//                NSDateFormatter *todayDateFormat = [[NSDateFormatter alloc] init];
//            
//                [todayDateFormat setDateFormat:@"MM/dd"];
//
//
//
            NSString *todayString = [dateFormat stringFromDate:today];
//
//                NSString *activityDateString = [dateFormat stringFromDate:event.startTime];
//
//






                if ([todayString isEqualToString:activity.activityDate]){

//add to events array. 

}

Any help would be greatly appreciate it. I’ve spent so many hours trying to get this work and have not been successful.

Thank you!


Source: ios

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.