开发者

Decrease time in objective-c

开发者 https://www.devze.com 2023-01-16 20:40 出处:网络
I have a number of hours and a number of minutes, and I want a reduce the time of 1 second. So, I think I must create a nsdate object with my time, and after find the method to decrease the time. I lo

I have a number of hours and a number of minutes, and I want a reduce the time of 1 second. So, I think I must create a nsdate object with my time, and after find the method to decrease the time. I looked in the apple docume开发者_如何学Pythonntation but I don't find how to do this.


You can use this

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MM/dd/yyyy"];
NewDateString = [formatter stringFromDate:[NSDate dateWithTimeIntervalSinceNow:-1]


You want NSDateComponents. Note, you need to use it with a specific calendar. A code example is listed on the page to which I linked.


Don't reinvent the wheel. There are many open source NSDate additions that you can use here. See here

0

精彩评论

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