how to add time in current time

后端 未结 4 2225
清歌不尽
清歌不尽 2021-02-14 07:01

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:59

    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.

提交回复
热议问题