如何设置NSPredicate以在当地时区返回日期?

时间:2012-09-15 06:53:22

标签: iphone objective-c ios xcode

我有一个谓词,它返回所选日期的事件,但它返回一个具有不同时区的日期。如何使谓词根据当地时区搜索日期?

NSTimeInterval time = floor([[NSDate date] timeIntervalSinceReferenceDate] / 86400.0) * 86400.0;
NSDate *start = [NSDate dateWithTimeIntervalSinceReferenceDate:time];

NSTimeInterval secondsInTwentyFourHours = (24 * 60 * 60);
NSDate *end = [start dateByAddingTimeInterval:secondsInTwentyFourHours];

// Create the predicate from the event store's instance method
NSPredicate *predicate = [store predicateForEventsWithStartDate:start endDate:end calendars:nil];
// Fetch all events that match the predicate
events = [store eventsMatchingPredicate:predicate];

0 个答案:

没有答案