开发者

Fetching time related data which includes current time

I have dat开发者_Python百科a stored where one of the entity's attributes is startTime which is stores as an NSNumber (NSTimeInterval) and another attribute with the item's duration.

How would I go about fetching the single item which is valid for "now" - i.e. teh item who's start time + duration includes the current time ([NSDate date])?


Have a look at this SO question: NSPredicate syntax for DATEADD?


You need to use an NSDateFormatter to grab the current time/date and then use NSDateComponents to break this into hours/mins/seconds (as required).

Then increment your startTime and duration onto it.

Then use the components to create a new NSDate which will be your result.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜