how to add time in current time

后端 未结 4 2037
梦如初夏
梦如初夏 2021-02-14 07:14

I\'m quite confused about this one.

I want to grab, current time, than according to condition, I want to add the required time, to the current time. for example.

4条回答
  •  误落风尘
    2021-02-14 07:53

    Do you mean current time, as in now?

    If so, this will do it for you:

    NSDate *now = [NSDate date]; // Grab current time
    NSDate *newDate = [now addTimeInterval:XXX] // Add XXX seconds to *now
    

    Where XXX is the time in seconds.

提交回复
热议问题