Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding 30 seconds to NSDate [duplicate]

How can I convert an NSDate to seconds? I need it in seconds so that I can added 30 secs to the date and then convert back to NSDate to schedule a local notification. Any better ways of doing that are welcome too.

like image 253
crazy_tiger_corp Avatar asked Dec 25 '22 13:12

crazy_tiger_corp


1 Answers

You can use dateByAddingTimeInterval and pass in the value as 30. This will return you an NSDate which will be 30 secs ahead.

NSDate *newDate = [previousDate dateByAddingTimeInterval:30];
like image 170
Shamas S Avatar answered Dec 31 '22 14:12

Shamas S