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.
current time = 06:47:10
//or should i hv to change this format to "2011-03-26 06:47:10 GMT"
if(a= 1 and b= min )
{ //add 1 min to
current time
}
else if(a= 1 and b= hour)
{ //add 1
hour to current time
}
else if(a= 1 and b=week )
{ //add 1
week to current time
}
Just need to add the output of the above condition to current time.
Please guide me with this.
Regards
Explanation: To add time, you add the hours together, then you add the minutes together. Because there are only 60 minutes in an hour, you cannot have a time whose minute value is greater than 60. In this case, subtract 60 minutes and add 1 more to the hour.
Adding Times Add the hours. Add the minutes. If the minutes are 60 or more, subtract 60 from the minutes and add 1 to hours.
To solve for time use the formula for time, t = d/s which means time equals distance divided by speed.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With